Skip to content

Commit 5da939d

Browse files
fix(button): use proper colors for the button states in the ionic theme (#30339)
Issue number: internal --------- ## What is the current behavior? The focused and hover states are appearing as an overlay of the contrast color on the buttons. ## What is the new behavior? - Updates hover and focus states to match Figma designs - Focus background should not change from the default - Hover background should be the shade for solid buttons, and use neutral subtlest for clear and outline buttons - Updates the clear button to use the new `foreground` variant ## Does this introduce a breaking change? - [ ] Yes - [x] No
1 parent 2a1addc commit 5da939d

File tree

27 files changed

+20
-22
lines changed

27 files changed

+20
-22
lines changed

core/src/components/button/button.common.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
:host(.button-clear) {
9797
--border-width: 0;
9898
--background: transparent;
99-
--color: #{ion-color(primary, base)};
99+
--color: #{ion-color(primary, foreground)};
100100
}
101101

102102
// Block Button
@@ -289,7 +289,7 @@ ion-ripple-effect {
289289
// Clear Button with Color
290290
:host(.button-clear.ion-color) .button-native {
291291
background: transparent;
292-
color: current-color(base);
292+
color: current-color(foreground);
293293
}
294294

295295
// Button in Toolbar

core/src/components/button/button.ionic.scss

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444

4545
:host(.button-solid) {
4646
--background-activated: #{globals.ion-color(primary, shade)};
47-
--background-hover: #{globals.ion-color(primary, contrast)};
48-
--background-focused: #{globals.ion-color(primary, contrast)};
49-
--background-focused-opacity: 0.24;
50-
--background-hover-opacity: 0.08;
47+
--background-hover: #{globals.ion-color(primary, shade)};
48+
--background-focused: transparent;
49+
--background-hover-opacity: 1;
5150
--ripple-opacity: var(--background-activated-opacity, 1);
5251
--ripple-color: var(--background-activated);
5352
}
@@ -58,10 +57,10 @@
5857
:host(.button-outline) {
5958
--border-width: #{globals.$ion-border-size-025};
6059
--border-style: #{globals.$ion-border-style-solid};
61-
--background-activated: #{globals.$ion-primitives-neutral-200};
60+
--background-activated: #{globals.$ion-bg-neutral-subtlest-press};
6261
--background-focused: transparent;
63-
--background-hover: #{globals.ion-color(primary, base)};
64-
--background-hover-opacity: 0.04;
62+
--background-hover: #{globals.$ion-bg-neutral-subtlest-press};
63+
--background-hover-opacity: 1;
6564
--ripple-opacity: var(--background-activated-opacity, 1);
6665
--ripple-color: var(--background-activated);
6766
}
@@ -70,10 +69,10 @@
7069
// --------------------------------------------------
7170

7271
:host(.button-clear) {
73-
--background-activated: #{globals.$ion-primitives-neutral-200};
72+
--background-activated: #{globals.$ion-bg-neutral-subtlest-press};
7473
--background-focused: transparent;
75-
--background-hover: #{globals.ion-color(primary, base)};
76-
--background-hover-opacity: 0.04;
74+
--background-hover: #{globals.$ion-bg-neutral-subtlest-press};
75+
--background-hover-opacity: 1;
7776
--ripple-opacity: var(--background-activated-opacity, 1);
7877
--ripple-color: var(--background-activated);
7978
}
@@ -217,16 +216,6 @@
217216
outline-offset: globals.$ion-border-size-050;
218217
}
219218

220-
/**
221-
* Only allow overriding of opacity here
222-
* as developers should not be overriding
223-
* colors when using the color prop.
224-
*/
225-
226-
:host(.button-solid.ion-color.ion-focused) .button-native::after {
227-
background: globals.current-color(contrast);
228-
}
229-
230219
// Button: Activated
231220
// --------------------------------------------------
232221

@@ -239,6 +228,15 @@
239228
background: transparent;
240229
}
241230

231+
// Button: Hover
232+
// --------------------------------------------------
233+
234+
@media (any-hover: hover) {
235+
:host(.button-solid.ion-color:hover) .button-native::after {
236+
background: globals.current-color(shade);
237+
}
238+
}
239+
242240
// Button: Disabled
243241
// --------------------------------------------------
244242

0 commit comments

Comments
 (0)