TimePicker

A field with one segment for hours, minutes, optional seconds and AM or PM. The value is always a 24 hour string such as 13:05 or 13:05:09, even on the 12 hour clock.

General

Type the digits and the focus moves to the next segment. Arrow Up and Down change the number.

Seconds

Add the seconds segment with withSeconds.

12 hour clock

Use format="12h" to show an AM or PM select. onChange still receives the 24 hour value.

Steps

Set how much Arrow Up and Down change each segment.

Controlled

onChange runs when the time is complete, and with an empty string when every segment is cleared. It does not run while the time is half typed.

Variants

Use filled, light, ghost or subtle with a type, as in the other fields.

APIs

TimePicker.Props

AttributeDescriptionTypeAccepted valuesDefault
valuetime as HH:mm or HH:mm:ss, to control the componentstring--
initialValuetime at the startstring-''
onChangecalled with the 24 hour time once it is complete(value: string) => void--
withSecondsshow the seconds segmentboolean-false
formatclock shownstring'12h', '24h'24h
hoursStepchange of the hours with the arrow keysnumber-1
minutesStepchange of the minutes with the arrow keysnumber-1
secondsStepchange of the seconds with the arrow keysnumber-1
hoursLabelaccessible name of the hours segmentstring-Hours
minutesLabelaccessible name of the minutes segmentstring-Minutes
secondsLabelaccessible name of the seconds segmentstring-Seconds
amPmLabelaccessible name of the AM or PM selectstring-AM or PM
amPmLabelstext of the AM and PM options{ am: string; pm: string }-AM, PM
disableddisable the componentboolean-false
typecolor of the fieldNormalTypes'default', 'primary', 'secondary', 'success', 'warning', 'error', 'info'default
roundedround the cornersboolean-false
filledfilled variantboolean-false
lightlight variantboolean-false
ghostoutline variantboolean-false
subtlesubtle variantboolean-false
...native props, passed to the rootHTMLAttributes'aria-label', 'id', 'className', ...-

Ref

The ref points at the root div, which has role="group".

Accessibility

The root is a group: name it with aria-label or aria-labelledby. Each segment is its own input with a name from hoursLabel, minutesLabel and secondsLabel, and the AM or PM select has amPmLabel.

KeyAction
0 to 9Type the segment, then move to the next one when it is full
Arrow Up and DownRaise and lower the segment by its step, wrapping around
Arrow Left and RightMove to the previous and next segment at the edge of the text
BackspaceOn an empty segment, move to the previous one
Edit this page on GitHub