Date Picker
A form field that shows a day, and opens a calendar in a bottom sheet to pick another.
Installation
This also adds Calendar, Bottom Sheet, Button and Icon.
Usage
- Tapping the field opens a sheet with a Calendar, at the chosen day's month.
- Tapping a day sets
value, emitschanged, and closes the sheet. - Tapping the backdrop, or dragging the sheet down, closes it without a change.
- The field shows the day as
Nov 20, 2026, orplaceholderwhile there's none.
Let the user clear it
While a day is chosen, the sheet has a Clear button under the calendar. It sets value to null, emits changed with null, and closes the sheet. Translate it with clearLabel.
Format the day
format takes any Angular date format: a name such as 'longDate', or a pattern. The field writes it in the app's LOCALE_ID, as the calendar does (see Languages).
Limit the days
min, max and weekStartsOn go to the calendar, as do its screen reader labels. To reach a day years away, tap the calendar's title.
With a label of your own
label is shown above the field and names it for screen readers. A label of your own, such as a Label, isn't tied to it, so give the picker an accessibility-label with the same text:
Disabled
A disabled picker dims and doesn't open.
Open from code
UiDatePicker has public open(), close() and toggle() methods. Get it with viewChild(UiDatePicker) and call them from a handler. open() and toggle() do nothing while disabled.
API
Accessibility
- The field is one button to VoiceOver and TalkBack, named by
label(oraccessibility-label), with the day it shows, or the placeholder, as its value: VoiceOver says "Ends on, Nov 20, 2026, button". Without either, its name is the text it shows. - A disabled field is dimmed to VoiceOver as well.
- In the sheet, each day is a button named by its whole date (see Calendar).
- The field is 48px tall. In the sheet, the calendar's controls and Clear are touch targets at least 48px each way, on phones 360px wide and up.
Related
- Calendar: the calendar on its own, in the page
- Select: a field that opens a list of options
- Bottom Sheet: the panel the calendar opens in
