TimePicker
An hour and a minute, each a spinbutton with buttons above and below, and AM and PM where the locale uses a 12-hour clock.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The label above it, and the group's accessible name. | |
value | string | bindable("09:00") | The time as "HH:MM" on the 24-hour clock, whatever the locale shows. Bind it with bind:value={name}. |
step | number | 5 | How many minutes one press or arrow key moves; minutes land on multiples of it (1 to 30), from 0 to the last multiple in the hour, so a step of 7 gives 0, 7, ... 56. |
locale | string | The locale that decides the 12- or 24-hour clock and the AM and PM words; the device's when left out. | |
disabled | boolean | false | Cannot be changed or focused. |
States
| State | Looks like |
|---|---|
24-hour | Two-digit hours, such as 07 : 30. |
12-hour | Hours 1 to 12 and an AM/PM pair beside them, the current one filled with primary. |
focused | The focus outline around the hours or minutes. |
disabled | The whole part at 50% opacity. |
Accessibility
| role | group of two spinbuttons (Hours, Minutes) with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext, and on a 12-hour clock a radiogroup of AM and PM |
| name | The label prop names the group; the spinbuttons are Hours and Minutes. |
| focus | Tab reaches the hours, then the minutes, then the chosen half of the day. The buttons above and below are left out of the Tab order. |
| keyboard | ArrowUp and ArrowDown move the hour by one or the minutes by one step, wrapping; on a 12-hour clock the hour stays in its half of the day. PageUp and PageDown move the minutes by 15, or by one step when the step is larger, rounded to whole steps. Home and End jump to the first and last (for minutes, the last multiple of the step). The arrow keys move between AM and PM. |
Theme tokens
color.surface color.border color.raised color.muted color.ink color.primary color.on-primary space.2 space.3 radius.md radius.sm text.label text.title text.caption
Example
<TimePicker label="Alarm" bind:value={alarm} />