Color Viewer Slider Example
WARNING! Some users of touch-based assistive technologies may experience difficulty utilizing widgets that implement this slider pattern because the gestures their assistive technology provides for operating sliders may not yet generate the necessary output. To change the slider value, touch-based assistive technologies need to respond to user gestures for increasing and decreasing the value by synthesizing key events. This is a new convention that may not be fully implemented by some assistive technologies. Authors should fully test slider widgets using assistive technologies on devices where touch is a primary input mechanism before considering incorporation into production systems.
Following is an example of a color viewer that demonstrates the slider 설계 패턴. 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.
유사한 예는 다음과 같습니다:
- Vertical Temperature Slider Example: Demonstrates using
aria-orientation
to specify vertical orientation andaria-valuetext
to communicate unit of measure for a temperature input. - Rating Slider Example: Horizontal slider that demonstrates using
aria-valuetext
to communicate current and maximum value of a rating input for a five star rating scale. - Media Seek Slider Example: Horizontal slider that demonstrates using
aria-valuetext
to communicate current and maximum values of time in media to make the values easy to understand for assistive technology users by converting the total number of seconds to minutes and seconds. - Horizontal Multi-Thumb Slider Example: Demonstrates using sliders with two thumbs to provide inputs for numeric ranges, such as for searching in a price range.
Example
접근성 특성
- To help assistive technology users understand that the color viewer is made of a group of three sliders, the sliders are wrapped in a
group
labeled by the heading that labels the color viewer. - The placement of the slider value above the thumb makes it easier for users with low vision to see the current value while dragging the thumb.
- To highlight the interactive nature of the thumb, the focus ring is drawn around the thumb and the value.
-
To ensure the borders of the slider rail, thumb and focus ring have sufficient contrast with the background when high contrast settings invert colors, the CSS
currentcolor
value for thestroke
property is used for the SVGrect
elements to synchronize the border color with text content. If specific colors were used to specify thestroke
property, the color of these elements would remain the same in high contrast mode, which could lead to insufficient contrast between them and their background or even make them invisible if their color were to match the high contrast mode background. NOTE: The SVG elements need to be inline to usecurrentcolor
.
키보드 지원
키 | 기능 |
---|---|
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. |
Role, Property, State, Tabindex 어트리뷰트
역할(role) | 어트리뷰트 | 엘리먼트 | 사용법 |
---|---|---|---|
group |
div |
|
|
aria-labelledby="IDREF" |
div |
Refers to the heading element that provides the accessible name for the group. | |
slider
|
div
|
|
|
tabindex="0"
|
div
|
Includes the slider thumb in the page tab sequence. | |
aria-valuemax="255"
|
div
|
Specifies the maximum value of the slider. | |
aria-valuemin="0"
|
div
|
Specifies the minimum value of the slider. | |
aria-valuenow="NUMBER"
|
div
|
Indicates the current value of the slider. | |
aria-labelledby="IDREF"
|
div
|
Refers to the element containing the name of the slider. | |
aria-hidden="true" |
svg |
Removes the SVG elements from the accessibility tree. Some assistive technologies will describe the SVG elements, unless they are explicitly hidden. |
Javascript와 CSS 소스 코드
- CSS: slider-color-viewer.css
- Javascript: slider-color-viewer.js
HTML Source Code