Radio Group Example Using aria-activedescendant
This example implements the features of the Radio Group 설계 패턴
for two radio groups -- one for choosing a pizza crust and another for choosing a delivery method.
This implementation uses aria-activedescendant for informing assistive technologies which radio button has visual focus.
유사한 예는 다음과 같습니다:
- Radio Group Example Using Roving tabindex: A radio button group that uses roving
tabindexfor managing keyboard focus. - Rating Radio Group Example: Radio group that provides input for a five-star rating scale.
Example
Pizza Crust
- Regular crust
- Deep dish
- Thin crust
Pizza Delivery
- Pick up
- Home Delivery
- Dine in Restaurant
접근성 특성
-
The radio button referenced by
aria-activedescendantis scrolled into view when it is not visible in the graphical rendering. This can occur under many conditions, but is most common when people with visual impairments use a browser's zoom feature to increase the size of content. - Uses CSS attribute selectors for synchronizing
aria-checkedstate with the visual state indicator. - Uses CSS
:hoverand:focuspseudo-classes for styling visual keyboard focus and hover.- The focus indicator encompasses both the radio button and label, making it easier to perceive which option is being chosen.
- Hover changes background of both the radio button and label, making it easier to perceive that clicking either the label or button will activate the radio button.
- The cursor is changed to a pointer when hovering over the radio button to help people with visual impairments identify it as an interactive element.
- Because transparent borders are visible on some systems with high contrast enabled, only the focused element has a visible border. When focusable elements are not focused, they have a 0-width border and additional padding equal in width to the border that is used to indicate focus.
-
To ensure the inline SVG radio button graphics in the CSS file have sufficient contrast with the background when high contrast settings change the color of text content,
CSS
forced-color-adjustis set toautoon thesvggraphics. This causes the colors of thestrokeandfillof the circle elements to be overridden by the high contrast color setting. To make the background of thecircleelements match the high contrast background color, thefill-opacityattribute of the outercircleis set to zero and thestroke-opacityattribute of the innercircleis set to zero. Ifforced-color-adjustwere not used to override the colors specified for thestrokeandfillproperties, those colors would remain the same in high contrast mode, which could lead to insufficient contrast between the radio circle elements and the background or even make them invisible if their color matched the high contrast mode background.
Note: The explicit setting offorced-color-adjustis necessary because some browsers do not useautoas the default value for SVG graphics.
키보드 지원
NOTE: When visual focus is on a radio button in the radio group, DOM focus remains on the radio group container and the value of aria-activedescendant on the radio group refers to the radio button that is visually indicated as focused.
Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator, not DOM focus.
For more information about this focus management technique, see
Using aria-activedescendant to Manage Focus.
| 키 | 기능 |
|---|---|
| Tab |
|
| Space |
|
| Down arrow Right arrow |
|
| Up arrow Left arrow |
|
Role, Property, State, Tabindex 어트리뷰트
| 역할(role) | Attributes | 엘리먼트 | 사용법 |
|---|---|---|---|
radiogroup |
ul |
Identifies the element as a container for a group of radio buttons. |
|
aria-labelledby="[IDREF]" |
ul |
Refers to the element that contains the label of the radio group. | |
tabindex="0" |
ul |
|
|
aria-activedescendant="[IDREF]" |
ul |
|
|
radio |
li |
|
|
aria-checked="false" |
li |
|
|
aria-checked="true" |
li |
|
Javascript와 CSS 소스 코드
- CSS: radio.css
- Javascript: radio-activedescendant.js
HTML Source Code