Date Picker Pattern
You'll learn how to build an accessible date picker that combines text input, calendar grid, and keyboard navigation for selecting dates inclusively.
Date pickers are among the most complex accessible widgets because they merge multiple interaction patterns: a text field (for manual entry), a popup dialog (for the calendar), and a grid (for navigating dates). Users need multiple ways to input dates—typing directly, clicking calendar dates, or navigating with arrow keys—and screen readers must announce everything clearly.
Core Structure
A proper accessible date picker includes:
- A text input field with
type="text"and a clear label describing the expected format (e.g., "MM/DD/YYYY") - A button adjacent to the input to trigger the calendar popup
- A dialog containing the calendar grid with
role="dialog"andaria-modal="true" - A grid structure using
role="grid",role="row", androle="gridcell"for dates - Column headers for day names (Mon, Tue, Wed...)
- Navigation controls to move between months/years
Key Behaviors
The calendar grid must support:
- Arrow keys to navigate between dates (Left/Right for days, Up/Down for weeks)
- Page Up/Down to move between months
- Home/End keys to jump to week start/end
- Escape to close the calendar and return focus to the input
- Enter/Space to select a date and close the calendar
The selected date gets aria-selected="true", and today's date should be marked (often with aria-current="date"). The dialog should announce the currently focused date as users navigate.
Think of it like giving someone three ways to tell you their birthday: they can write it down, point to it on a wall calendar, or walk through the calendar day-by-day until they find it.
Key Takeaway: An accessible date picker provides both text input and calendar grid interfaces, with comprehensive keyboard navigation and clear screen reader announcements throughout the selection process.