third_party/aria-practices/src/content/patterns/spinbutton/examples/datepicker-spinbuttons.html
This pattern has been deprecated, and will be removed in a future version of the ARIA Authoring Practices. The Quantity Spin Button should be used as an alternative to this pattern.
The following example uses the Spin Button Pattern to implement a date picker. It includes three spin buttons: one for setting the day, a second for month, and a third for year.
Similar examples include:
Choose a Date
current value is Friday, June 30th, 2019
30
1
2
May
June
July
2018
2019
2020
div that contains a date string that reflects the current values of the three spin buttons. This enables screen reader users to easily perceive the date represented by the three buttons without having to navigate to all three buttons and remember the value of each one; it is the screen reader user equivalent to seeing the date at a glance.aria-valuetext to properly pronounce the day, e.g. first, second, third ...aria-valuetext to properly pronounce the month instead of the numeric value, e.g. January, February, ...div with role spinbutton so they can be separately focusable by users of touch screen readers. However, they are excluded from the page Tab sequence with tabindex="-1" because they are redundant with the arrow key support provided to keyboard users.The spin buttons provide the following keyboard support described in the Spin Button Pattern.
| Key | Function |
|---|---|
| Down Arrow |
| | Up Arrow |
| | Page Down |
| | Page Up |
| | Home | Decreases to minimum value. | | End | Increases to maximum value. |
| Role | Attribute | Element | Usage |
|---|---|---|---|
group | div |
div as a group.|
| | aria-labelledby="IDREFs" | div |
div elements that provide the accessible name for the group.div that contains a string specifying the current date represented by the values of the three spin buttons, which is updated by JavaScript as users change the values of the spin buttons.|
| spinbutton | | div | Identifies the div element as a spinbutton. |
| | aria-label="NAME_STRING" | div | Defines the accessible name for each spin button (e.g. day, month and year). |
| | aria-valuenow="NUMBER" | div |
|
| | aria-valuetext="DAY_NUMBER_STRING" or
aria-valuetext="MONTH_STRING" | div |
|
| | aria-valuemin="NUMBER" | div | Indicates the minimum allowed value for the spin button. |
| | aria-valuemax="NUMBER" | div |
|
| | aria-hidden="true" |
div.nextdiv.previous| For assistive technology users, hides the text showing the next and previous values that is displayed adjacent to the up and down arrow icons since it would otherwise add superfluous elements to the screen reader reading order that are likely to be more confusing than helpful. |
| | aria-label="NAME_STRING" | button | Defines the accessible name for each increase and decrease button (Next Day, Previous Day, Next Month, Previous Month, Next year, and Previous Year). |
| | 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. |
To copy the following HTML code, please open it in CodePen.