StartFoundationsComponentsContent

Time picker

A time picker is a form field for a time of day. People type any time or pick a suggestion; the form gets a 24-hour time such as 19:30.

Stable Figma
OverviewUsageAPIAccessibility
<tk-field label="Start time" helper="For example, 2:30 PM">
  <tk-time-picker name="start" interval="15" min="09:00" max="17:00"></tk-time-picker>
</tk-field>

Put the time picker in a Field to give it a label, helper, and error. Without a Field, set aria-label. Inside a Field, set required and disabled on the Field.

Anatomy

Part What it is
tk-time-picker the element; one Tab stop
field part the bordered box; fills its container
input part the native text input; always typable
clock icon at the end of the box; decoration, not a button
listbox part the suggestion list; as wide as the box; opens below it, or above near the bottom of the screen

The list only suggests. People can type 7:37 PM even when the list steps by 30 minutes.

Sizes

<tk-time-picker aria-label="Pickup time" value="09:30"></tk-time-picker>
<tk-time-picker size="large" aria-label="Return time" value="17:00"></tk-time-picker>
size Height Padding-inline Value text Suggestion row
medium (default) 32px space-8 Body Small (14/20) 32px
large 36px space-10 Body Medium (16/24) 36px

The heights match Input and Button.

States

<tk-time-picker aria-label="Opens at" value="08:00" readonly></tk-time-picker>
<tk-time-picker aria-label="Closes at" value="18:00" disabled></tk-time-picker>
<tk-field label="Reminder time" error="Enter a real time">
  <tk-time-picker name="reminder"></tk-time-picker>
</tk-field>

The box doesn't change on hover. On focus, its border takes the focus color and grows thicker inward; it stays that way while the list is open.

  • readonly: people can focus and copy the time; the list doesn't open.
  • disabled: nothing works, and the time is left out of the form.
  • Error: set error on the Field. The border turns red and the message shows under the box.

Typing a time

The text is read when people press Enter or leave the field. Case doesn't matter, and "p.m." works too.

  • 21:30, 9:30, or 14.00
  • 9 or 21: a whole hour
  • 930, 0930, or 1730
  • any of these with AM or PM: 9:30pm, 9 PM, 930p

Without AM or PM, the time reads as 24-hour: 9:30 is morning. With AM or PM, hours go from 1 to 12; 12 AM is midnight. Words such as "noon" don't work.

After a time is read, the field shows it as "9:30 AM", or "09:30" with hour-cycle="h23". If the text isn't a real time, the field keeps it, clears the value, and blocks the form from submitting.

Suggestions

<tk-time-picker aria-label="Quiet hours start" hour-cycle="h23"
  interval="60" min="22:00" max="07:00"></tk-time-picker>
  • interval sets the step between suggestions in minutes: 30 by default, 15 for scheduling. It must divide 60. It never rejects a typed time.
  • min and max limit the list and the value. When min is later than max, the window crosses midnight: 22:00 to 07:00 lists 22:00 through 07:00.
  • A click in the field, or Down, opens the list. Typing never opens or filters it.
  • The list opens at the chosen time, or at the next suggestion after now. A check marks the chosen time.
  • Focus stays in the field. Moving through the list doesn't change the value; Enter, a click, or Tab on a highlighted row does.
  • Esc or a click outside closes the list without picking.