Color Viewer Slider Example with Mobile Support
++ Following is an example of a color viewer that demonstrates the + slider design pattern. + Change the background of the color view box by adjusting the sliders for red, green, and blue values. + The HEX and RGB values of the chosen color are displayed by the color view box. +
+Similar examples include:
+-
+
- + Slider Example: + Color viewer with three sliders to choose RGB colors. + +
- + Slider Examples with aria-orientation and aria-valuetext: + Three thermostat control sliders that demonstrate using aria-orientation and aria-valuetext. + +
+
+
+ Example
+
+
+
+
+ Accessibility Features
+-
+
- + The three sliders are wrapped in a group to help assistive technology users understand that all three elements together represent a color viewer. + +
- The placement of the slider value above the thumb supports users with low vision by making it easier for them to view the value as they change the slider position. +
- Use of SVG enables high contrast support by providing a means for
text
andrect
element to adapt to high contrast colors using thecurrentColor
value for thestroke
andfill
properties .
+ -
+ The increase and decrease buttons are included to support mobile assistive technology users in changing the value of the sliders. The buttons are excluded from the page Tab sequence with
tabindex="-1"
because they are redundant with the arrow key support of the slider. +
+ - The
svg
graphics contained in thebutton
elements have an attributefocusable="false"
to mitigate a bug in Internet Explorer 11 that sets focusable to true when ansvg
image is inside abutton
element.
+
Keyboard Support
+ +Slider
+Key | +Function | +
---|---|
Right Arrow | +Increases slider value one step. | +
Up Arrow | +Increases slider value one step. | +
Left Arrow | +Decreases slider value one step. | +
Down Arrow | +Decreases slider value one step. | +
Page Up | +Increases slider value multiple steps. In this slider, jumps ten steps. | +
Page Down | +Decreases slider value multiple steps. In this slider, jumps ten steps. | +
Home | +Sets slider to its minimum value. | +
End | +Sets slider to its maximum value. | +
Increase and Decrease Buttons
+Key | +Function | +
---|---|
Space, Enter | +Change the value of the slider by the value associated with the button. | +
Role, Property, State, and Tabindex Attributes
+Slider
+Role | +Attribute | +Element | +Usage | +
---|---|---|---|
group |
+ + | div |
+
+
|
+
+ | aria-labelledby="IDREF" |
+ div |
+
+
|
+
+ slider
+ |
+ + |
+ div
+ |
+
+
|
+
+ |
+ tabindex=
+ |
+
+ div
+ |
+ Includes the slider thumb in the page tab sequence. | +
+ |
+ aria-valuemax=
+ |
+
+ div
+ |
+ Specifies the maximum value of the slider. | +
+ |
+ aria-valuemin=
+ |
+
+ div
+ |
+ Specifies the minimum value of the slider. | +
+ |
+ aria-valuenow=
+ |
+
+ div
+ |
+ Indicates the current value of the slider. | +
+ |
+ aria-labelledby=
+ |
+
+ div
+ |
+ Refers to the element containing the name of the slider. | +
+ | aria-label="NAME_STRING" |
+ button |
+ Defines the accessible name for each increase and decrease button (-10, -1, +1, and +10). |
+
+ | tabindex="-1" |
+ button |
+ Removes the decrease and increase buttons from the page Tab sequence while keeping them focusable so they can be accessed with touch-based assistive technologies. | +
Increase and Decrease Buttons
+Role | +Attribute | +Element | +Usage | +
---|---|---|---|
+ | tabindex= |
+ button |
+
+
|
+
+ | aria-label= |
+ button |
+
+
|
+
+ | focusable= |
+ svg |
+
+ focusable= fixes an Internet Explorer 11 issue that makes SVG images within button elements focusable= by default.
+ |
+
Javascript and CSS Source Code
+-
+
- CSS: slider-color-viewer.css +
- Javascript: slider-color-viewer.js +
HTML Source Code
+ +
+
+
+