Skip to content

Commit 742ad4a

Browse files
Badge - Update colors to increase contrast for a11y (HDS-4335) (#2695)
1 parent 109d71f commit 742ad4a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.changeset/old-snakes-judge.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hashicorp/design-system-components": minor
3+
---
4+
5+
`Badge` - Update foreground and background colors to improve contrast for a11y
6+
7+
`BadgeCount` - Update foreground color of neutral variant to improve contrast for a11y

packages/components/src/styles/components/badge-count.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $hds-badge-count-size-props: (
6767
.hds-badge-count--color-neutral {
6868
&.hds-badge-count--type-filled {
6969
color: var(--token-color-foreground-primary);
70-
background-color: var(--token-color-surface-strong);
70+
background-color: var(--token-color-palette-neutral-200);
7171
}
7272

7373
&.hds-badge-count--type-inverted {

packages/components/src/styles/components/badge.scss

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ $hds-badge-colors-props: (
3434

3535

3636
.hds-badge {
37+
// Redefine color values to increase contrast
38+
--token-color-surface-success: var(--token-color-palette-green-100);
39+
--token-color-foreground-success-on-surface: var(--token-color-palette-green-400);
40+
--token-color-surface-warning: var(--token-color-palette-amber-100);
41+
--token-color-foreground-warning-on-surface: var(--token-color-palette-amber-400);
42+
--token-color-surface-critical: var(--token-color-palette-red-100);
43+
--token-color-foreground-critical-on-surface: var(--token-color-palette-red-400);
44+
--token-color-surface-highlight: var(--token-color-palette-purple-100);
45+
--token-color-foreground-highlight-on-surface: var(--token-color-palette-purple-400);
46+
3747
display: inline-flex;
3848
align-items: center;
3949
max-width: 100%;
@@ -111,7 +121,7 @@ $hds-badge-size-props: (
111121
.hds-badge--color-neutral {
112122
&.hds-badge--type-filled {
113123
color: var(--token-color-foreground-primary);
114-
background-color: var(--token-color-surface-strong);
124+
background-color: var(--token-color-palette-neutral-200);
115125
}
116126

117127
&.hds-badge--type-inverted {

0 commit comments

Comments
 (0)