Skip to content

Commit f2bc09d

Browse files
committed
docs(color-slider): enhance README with accessible labels for color slider
1 parent f677eb5 commit f2bc09d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

packages/color-slider/README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The current color formats supported are as follows:
8181
For a complete list of supported color formats, see the [ColorController documentation](/tools/color-controller#supported-color-formats).
8282

8383
**Please note for the following formats: HSV, HSVA, HSL, HSLA**
84+
8485
When using the HSL or HSV formats, and a color's value (in HSV) is set to 0, or its luminosity (in HSL) is set to 0 or 1, the hue and saturation values may not be preserved by the element's `color` property. This is detailed in the [colorjs documentation](https://colorjs.io/docs/). Seperately, the element's `value` property is directly managed by the hue as represented in the interface.
8586

8687
### Accessibility
@@ -91,6 +92,27 @@ The `<sp-color-slider>` is rendered with appropriate ARIA attributes to ensure a
9192
- Provides value text announcements for screen readers
9293
- Supports full keyboard navigation
9394

95+
#### Accessible Labels
96+
97+
The color slider includes an accessible label that describes what the slider controls. By default, the label is set to "hue", but you can customize it using the `label` attribute:
98+
99+
```html
100+
<!-- Default label -->
101+
<sp-color-slider></sp-color-slider>
102+
103+
<!-- Custom label -->
104+
<sp-color-slider label="Color hue"></sp-color-slider>
105+
<sp-color-slider label="Saturation level"></sp-color-slider>
106+
```
107+
108+
The label serves several important accessibility purposes:
109+
110+
- **Screen Reader Announcements**: Screen readers announce the label when the slider receives focus, helping users understand what they're adjusting
111+
- **ARIA Labeling**: The label is used as the `aria-label` attribute on the internal range input
112+
- **Context for Value Changes**: When the slider value changes, screen readers announce both the current value and the label for context
113+
114+
For example, when a user focuses on a color slider with `label="Color hue"`, screen readers will announce something like "Color hue slider, 180 degrees" to provide clear context about what the control does and its current value.
115+
94116
#### Keyboard Navigation
95117

96118
<sp-table>
@@ -117,11 +139,11 @@ The `<sp-color-slider>` is rendered with appropriate ARIA attributes to ensure a
117139
</sp-table-row>
118140
<sp-table-row>
119141
<sp-table-cell><kbd>Page Down</kbd></sp-table-cell>
120-
<sp-table-cell>Decreases the hue value by a larger step</sp-table-cell>
142+
<sp-table-cell>Decreases the hue value by a larger step(10% of total value)</sp-table-cell>
121143
</sp-table-row>
122144
<sp-table-row>
123145
<sp-table-cell><kbd>Page Up</kbd></sp-table-cell>
124-
<sp-table-cell>Increases the hue value by a larger step</sp-table-cell>
146+
<sp-table-cell>Increases the hue value by a larger step(10% of total value)</sp-table-cell>
125147
</sp-table-row>
126148
<sp-table-row>
127149
<sp-table-cell><kbd>Home</kbd></sp-table-cell>

0 commit comments

Comments
 (0)