Select time
Time pickers let people select a time, on a dial or by typing it. Compose a TimePicker from its parts. The picker has no built-in text, apart from what the locale provides: write the text of each part yourself, in your language.
For a time typed without a dial, use the time input alone.
import {
DialogTrigger,
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerDialog,
TimePickerHeader,
TimePickerInput,
TimePickerModeToggle,
TimePickerPeriodSelector,
} from '@material-web/react'
import { Time } from '@internationalized/date'
import { Heading } from 'react-aria-components'Basic time picker
Write the parts of a TimePicker as its children, with their text, and name the picker with an aria-label. A picker is shown where it is written, and does not open on its own: this one is in a TimePickerDialog, as a modal time picker.
import { Time } from '@internationalized/date'
import {
Button,
DialogTrigger,
Icon,
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerDialog,
TimePickerHeader,
TimePickerInput,
TimePickerModeToggle,
TimePickerPeriodSelector,
type TimePickerDisplayMode,
type TimePickerRenderProps,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type TimeValue } from 'react-aria-components'
const parts = ({ displayMode, selection }: TimePickerRenderProps) => (
<>
<TimePickerHeader>
<Heading slot="title">{displayMode === 'picker' ? 'Select time' : 'Enter time'}</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput hourLabel="Hour" minuteLabel="Minute" />
<TimePickerPeriodSelector aria-label="Select AM or PM" />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</>
)
export default function Basic() {
const [time, setTime] = useState<TimeValue | null>(new Time(7, 0))
const [picked, setPicked] = useState(time)
const [displayMode, setDisplayMode] = useState<TimePickerDisplayMode>('picker')
return (
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(time)}>
<Button variant="outlined">
<Icon name="schedule" />
{time ? time.toString() : 'Pick a time'}
</Button>
<TimePickerDialog
modeToggle={
<TimePickerModeToggle
displayMode={displayMode}
onPress={() => setDisplayMode(displayMode === 'picker' ? 'input' : 'picker')}
aria-label={
displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to touch input mode'
}
/>
}
dismissButton={
<Button variant="text" slot="close">
Cancel
</Button>
}
confirmButton={
<Button variant="text" slot="close" isDisabled={!picked} onPress={() => setTime(picked)}>
OK
</Button>
}
>
<TimePicker aria-label="Time" value={picked} onChange={setPicked} displayMode={displayMode}>
{parts}
</TimePicker>
</TimePickerDialog>
</DialogTrigger>
)
}A TimePicker is shown where it is written, as the controlled picker is, or in a dialog. It has two variants, the dial and the input: show both with a mode toggle between them, or the input alone.
Composition
A TimePicker is composed of these parts. It holds a TimePickerHeader and, under it, a TimePickerContent, which hold the others:
| Part | In | Use |
|---|---|---|
TimePickerHeader | TimePicker | The header |
Heading with slot="title" | TimePickerHeader | The title, which names the dialog the picker is in |
TimePickerContent | TimePicker | The content, under the header |
TimePickerInput | TimePickerContent | The hour and the minute |
TimePickerPeriodSelector | TimePickerContent | AM and PM |
TimePickerDial | TimePickerContent | The dial |
Leave out a part to do without it. Pass a function as the picker's children to write text that follows the display mode and the selection, such as the title. It is called with { displayMode, selection }.
const parts = ({ displayMode, selection }: TimePickerRenderProps) => (
<>
<TimePickerHeader>
<Heading slot="title">{displayMode === 'picker' ? 'Select time' : 'Enter time'}</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput hourLabel="Hour" minuteLabel="Minute" />
<TimePickerPeriodSelector aria-label="Select AM or PM" />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</>
)Set the picker's props on the TimePicker. They are those of React Aria's TimeField, except minValue, maxValue and granularity: a picker sets the hour and the minute.
Modal time picker
To show the picker in a dialog, put it in a TimePickerDialog. Pass the dialog's buttons as confirmButton and dismissButton, and a TimePickerModeToggle as modeToggle, which the dialog places at the start of its buttons.
Hold the display mode in your own state. Pass it as displayMode to the picker and to the mode toggle, and switch it in the toggle's onPress. The toggle shows a keyboard icon in picker mode and a clock icon in input mode.
The picker reports every change through onChange. To keep the time unchanged until it is confirmed, hold the picked time in your own state and save it in the confirm button's onPress.
const [time, setTime] = useState<TimeValue | null>(new Time(7, 0))
const [picked, setPicked] = useState(time)
const [displayMode, setDisplayMode] = useState<TimePickerDisplayMode>('picker')
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(time)}>
<Button variant="outlined">Pick a time</Button>
<TimePickerDialog
modeToggle={
<TimePickerModeToggle
displayMode={displayMode}
onPress={() => setDisplayMode(displayMode === 'picker' ? 'input' : 'picker')}
aria-label={displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to touch input mode'}
/>
}
dismissButton={<Button variant="text" slot="close">Cancel</Button>}
confirmButton={
<Button variant="text" slot="close" isDisabled={!picked} onPress={() => setTime(picked)}>
OK
</Button>
}
>
<TimePicker aria-label="Time" value={picked} onChange={setPicked} displayMode={displayMode}>
{parts}
</TimePicker>
</TimePickerDialog>
</DialogTrigger>- As in a date picker's dialog, a button with
slot="close"closes the dialog after its ownonPress. Escape and a press outside the dialog close it too. SetisDismissable={false}to keep a press outside from closing it, andisKeyboardDismissDisabledto keep Escape from closing it. - The dialog is laid out in the locale's direction. The hour is on the left of the minute in either direction.
- In a window too short for the picker, such as a phone in landscape with the horizontal layout, the picker scrolls inside the dialog and the buttons stay under it.
Time input
For a time that does not need a dial, show the input alone: use input mode and leave out the dial and the mode toggle.
import { Time } from '@internationalized/date'
import {
Button,
DialogTrigger,
Icon,
TimePicker,
TimePickerContent,
TimePickerDialog,
TimePickerHeader,
TimePickerInput,
TimePickerPeriodSelector,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type TimeValue } from 'react-aria-components'
export default function InputOnly() {
const [time, setTime] = useState<TimeValue | null>(new Time(7, 0))
const [picked, setPicked] = useState(time)
return (
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(time)}>
<Button variant="outlined">
<Icon name="schedule" />
{time ? time.toString() : 'Enter a time'}
</Button>
<TimePickerDialog
dismissButton={
<Button variant="text" slot="close">
Cancel
</Button>
}
confirmButton={
<Button variant="text" slot="close" isDisabled={!picked} onPress={() => setTime(picked)}>
OK
</Button>
}
>
<TimePicker aria-label="Time" value={picked} onChange={setPicked} displayMode="input">
<TimePickerHeader>
<Heading slot="title">Enter time</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput hourLabel="Hour" minuteLabel="Minute" />
<TimePickerPeriodSelector aria-label="Select AM or PM" />
</TimePickerContent>
</TimePicker>
</TimePickerDialog>
</DialogTrigger>
)
}Slots
Header
- title
| Slot | Child | Use |
|---|---|---|
title | A Heading | The picker's title. In a TimePickerDialog, it names the dialog. |
Dialog
- close
| Slot | Child | Use |
|---|---|---|
close | Any button, such as the confirm and dismiss buttons | Closes the TimePickerDialog after its own onPress |
Hour and minute
TimePickerInput shows the hour and the minute, with the locale's separator between them.
- A press focuses the hour or the minute. The arrow keys step it, digits type it and move on to the next when it is full, and Backspace clears it.
- Clearing the hour or the minute leaves the value as it was until the whole time is cleared. While one is cleared, a selection on the dial fills it back and keeps the other as typed. On a 12-hour clock the period is never cleared, so the value stays.
- The hour is written with two digits, as in
07. SetshouldForceLeadingZeros={false}on the picker to write it as the locale does.
Input mode
In input mode, the hour and the minute are text inputs. Set hourLabel and minuteLabel to label them. Without a label, an input is named with the locale's name for the field. The inputs are marked as required or invalid, and described, as the picker is.
The inputs are edited as any text input, with these rules:
- An input takes digits only, two at most: the decimal digits of any script, and the Han numerals of
hanidec. A digit typed into a full input starts it over. Pasted text is taken whole. - Each number typed sets the time at once. A digit that would take the number past the clock's range is refused, and the text and the caret stay as they were.
- The focus moves from the hour to the minute once the hour has two digits, or one digit from 2 to 9 on a 12-hour clock. Enter in the hour moves the focus to the minute too, and does not submit a form around the picker. Enter in the minute submits the form.
- A cleared hour is midnight, or noon in the afternoon, and a cleared minute is zero.
A time set by the dial or the period selector is written in the inputs in the locale's digits. Switching to input mode moves the focus to the input of the selection.
Dial
TimePickerDial sets the hour or the minute, whichever is the selection:
- A press anywhere on the dial, on a number or off it, selects the nearest hour, or the nearest five minutes.
- A drag follows the pointer and selects the hour, or the exact minute.
- After the pointer selects an hour, the dial moves on to the minutes. After the keyboard selects one, the dial stays on the hours.
With the keyboard, Tab moves the focus to the numbers, the arrow keys move along them, and Enter or Space selects one. Selecting the number that is already selected sets a time from the placeholder, or fills a cleared hour or minute back. Tab lands on the first number or the one last focused, not on the selected one.
Period selector
TimePickerPeriodSelector selects AM or PM, written as the locale writes them. Selecting one moves the time forward or back by twelve hours. It shows nothing on a 24-hour clock.
Selection
The selection is the part of the time that the dial sets: hour (the default) or minute. Focusing the hour or the minute selects it. Set the initial selection with defaultSelection, or control it with selection and onSelectionChange.
Controlled
Pass times as Time objects from @internationalized/date, in value, defaultValue and placeholderValue. A CalendarDateTime or a ZonedDateTime works too, and keeps its date. Set the initial time with defaultValue, or control it with value and onChange. onChange is called with the time when the dial is turned, the period is selected or a time is typed.
This picker is controlled, and so is its selection. Both are written under it.
Select time
import { Time } from '@internationalized/date'
import {
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerHeader,
TimePickerInput,
type TimePickerSelection,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type TimeValue } from 'react-aria-components'
export default function Controlled() {
const [time, setTime] = useState<TimeValue | null>(new Time(20, 0))
const [selection, setSelection] = useState<TimePickerSelection>('hour')
return (
<div className="flex flex-col gap-space-200">
<TimePicker
aria-label="Time"
hourCycle={24}
value={time}
onChange={setTime}
selection={selection}
onSelectionChange={setSelection}
>
<TimePickerHeader>
<Heading slot="title">Select time</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</TimePicker>
<span className="px-space-300 text-body-md text-on-surface-variant">
{time ? time.toString() : 'null'}, {selection}
</span>
</div>
)
}No time
With no time, the dial shows placeholderValue, which is midnight by default, and the hour and the minute show their placeholders. The first selection on the dial takes the rest of the time from placeholderValue, keeps an hour or a minute typed meanwhile, and calls onChange with the whole time. Typing calls onChange once both the hour and the minute are typed.
import { Time } from '@internationalized/date'
import {
Button,
DialogTrigger,
Icon,
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerDialog,
TimePickerHeader,
TimePickerInput,
TimePickerPeriodSelector,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type TimeValue } from 'react-aria-components'
export default function Empty() {
const [time, setTime] = useState<TimeValue | null>(null)
const [picked, setPicked] = useState(time)
return (
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(time)}>
<Button variant="outlined">
<Icon name="schedule" />
{time ? time.toString() : 'Pick a time'}
</Button>
<TimePickerDialog
dismissButton={
<Button variant="text" slot="close">
Cancel
</Button>
}
confirmButton={
<Button variant="text" slot="close" isDisabled={!picked} onPress={() => setTime(picked)}>
OK
</Button>
}
>
<TimePicker
aria-label="Time"
value={picked}
onChange={setPicked}
placeholderValue={new Time(12, 0)}
>
{({ selection }) => (
<>
<TimePickerHeader>
<Heading slot="title">Select time</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput />
<TimePickerPeriodSelector aria-label="Select AM or PM" />
<TimePickerDial
aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'}
/>
</TimePickerContent>
</>
)}
</TimePicker>
</TimePickerDialog>
</DialogTrigger>
)
}Display mode
The display mode is picker (the default), which shows the dial, or input, which hides the dial and shows the hour and the minute as text inputs, with hourLabel and minuteLabel under them. Set it with displayMode.
A picker does not switch its display mode itself. To let people switch it, hold it in your own state and add a TimePickerModeToggle, as in the modal time picker.
Horizontal layout
Set layout to vertical (the default) to put the dial under the time, or to horizontal to put it beside the time, as on a phone in landscape.
import { Time } from '@internationalized/date'
import {
Button,
DialogTrigger,
Icon,
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerDialog,
TimePickerHeader,
TimePickerInput,
TimePickerModeToggle,
TimePickerPeriodSelector,
type TimePickerDisplayMode,
type TimePickerRenderProps,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type TimeValue } from 'react-aria-components'
const parts = ({ displayMode, selection }: TimePickerRenderProps) => (
<>
<TimePickerHeader>
<Heading slot="title">{displayMode === 'picker' ? 'Select time' : 'Enter time'}</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput hourLabel="Hour" minuteLabel="Minute" />
<TimePickerPeriodSelector aria-label="Select AM or PM" />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</>
)
export default function Horizontal() {
const [time, setTime] = useState<TimeValue | null>(new Time(7, 0))
const [picked, setPicked] = useState(time)
const [displayMode, setDisplayMode] = useState<TimePickerDisplayMode>('picker')
return (
<DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(time)}>
<Button variant="outlined">
<Icon name="schedule" />
{time ? time.toString() : 'Pick a time'}
</Button>
<TimePickerDialog
modeToggle={
<TimePickerModeToggle
displayMode={displayMode}
onPress={() => setDisplayMode(displayMode === 'picker' ? 'input' : 'picker')}
aria-label={
displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to touch input mode'
}
/>
}
dismissButton={
<Button variant="text" slot="close">
Cancel
</Button>
}
confirmButton={
<Button variant="text" slot="close" isDisabled={!picked} onPress={() => setTime(picked)}>
OK
</Button>
}
>
<TimePicker
aria-label="Time"
value={picked}
onChange={setPicked}
displayMode={displayMode}
layout="horizontal"
>
{parts}
</TimePicker>
</TimePickerDialog>
</DialogTrigger>
)
}Form props
Set isDisabled to disable a picker: the time, the period selector and the dial are dimmed, and cannot be pressed, typed in or focused. Set isReadOnly to keep the time as it is: the hour and the minute can be focused, but typing and the period selector change nothing, and the numbers of the dial are dimmed and cannot be selected.
Disabled
Read-only
import { Time } from '@internationalized/date'
import {
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerHeader,
TimePickerInput,
type TimePickerRenderProps,
} from '@material-web/react'
import { Heading } from 'react-aria-components'
const parts =
(title: string) =>
({ selection }: TimePickerRenderProps) => (
<>
<TimePickerHeader>
<Heading slot="title">{title}</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</>
)
export default function FormProps() {
const time = new Time(20, 0)
return (
<>
<TimePicker aria-label="Disabled time" hourCycle={24} defaultValue={time} isDisabled>
{parts('Disabled')}
</TimePicker>
<TimePicker aria-label="Read-only time" hourCycle={24} defaultValue={time} isReadOnly>
{parts('Read-only')}
</TimePicker>
</>
)
}- Form: Set
nameto include the picker in a form. The time is submitted as a string such as07:30:00. See Forms. - Focus: Set
autoFocusto focus the hour when the picker is shown.
Validation
Set isRequired to require a time, or pass a validate function for a rule of your own, as with React Aria's TimeField. A picker that fails either one blocks its form from being submitted, and is then marked as invalid. With validationBehavior set to aria, it is marked as invalid at once and the form is submitted. Set isInvalid to mark a picker as invalid yourself.
Note: An invalid picker is reported to assistive technology, and looks the same as a valid one. A picker has no minValue and no maxValue: check the time in validate.
12-hour and 24-hour clocks
The clock is the locale's, 12-hour or 24-hour. Set hourCycle to 12 or 24 to choose one yourself.
Set hourCycle={24} for a 24-hour clock, which is the default in a locale that uses one. The dial then shows the hours 0 to 11 on the outer ring and 12 to 23 on the inner ring, and a press or a drag selects from one ring or the other by its distance from the center. The period selector shows nothing.
Select time
import { Time } from '@internationalized/date'
import {
TimePicker,
TimePickerContent,
TimePickerDial,
TimePickerHeader,
TimePickerInput,
} from '@material-web/react'
import { Heading } from 'react-aria-components'
export default function TwentyFourHour() {
return (
<TimePicker aria-label="Time" hourCycle={24} defaultValue={new Time(20, 0)}>
{({ selection }) => (
<>
<TimePickerHeader>
<Heading slot="title">Select time</Heading>
</TimePickerHeader>
<TimePickerContent>
<TimePickerInput />
<TimePickerDial aria-label={selection === 'hour' ? 'Select hour' : 'Select minute'} />
</TimePickerContent>
</>
)}
</TimePicker>
)
}Text and locale
Write the picker's text in the parts: the title, the labels under the inputs, and the aria-label of the dial, the period selector and the mode toggle. The rest follows the locale. To set a locale, wrap the picker in an I18nProvider from react-aria-components.
- The clock is the locale's, 12 or 24 hours, unless you set
hourCycle. So is the separator between the hour and the minute. - AM and PM are written as the locale writes them.
- The dial's numbers are written in the locale's digits, with zero as
00, and each is named as the locale counts hours and minutes, such as7 hours. In a locale that counts a 12-hour clock from 0, such as Japanese, the top number is 0, written00.
Customization
Pass classes in className to restyle a picker, or one of its parts: a TimePickerHeader, a TimePickerContent, a TimePickerPeriodSelector, a TimePickerDial and a TimePickerDialog take className too. A TimePickerInput takes none. See Styling for the classes, the states and the theme.
- Parts: Leave out a part to do without it, such as the dial and the mode toggle for a time input.
- Mode toggle: A
TimePickerModeToggletakes the props of an icon button, such as itsvariant. - Text: Write the text of each part yourself. See Text and locale.
Use cases
Material lists what people should be able to do with assistive technology:
- Select or enter hours, minutes, seconds, or milliseconds
- Choose between 12-hour or 24-hour clock format
- Enter time selection directly using input fields
Interaction and style
- States: The hour and minute boxes show a state layer on hover and on a press, and the period options a state layer on hover and a ripple on a press. Keyboard focus shows a focus ring on the hour or the minute over the dial, on a period option and on a number of the dial, and a press on the hour or the minute does not. In input mode, the focused box is outlined 2dp instead.
- Touch target: The mode toggle has a 48dp touch target, as Material requires. The dial takes a press anywhere on its face, and selects the nearest number.
- Motion: With reduced motion, the display modes swap and the hand turns at once.
- Forced colors: In forced colors, the hand, the selected period and the selected hour or minute are filled with the system's highlight color, and the dial and the hour and minute boxes keep an edge.
- Right to left: In a right-to-left locale, the dialog is laid out right to left, with the period selector first, but the hour stays before the minute.
- Text input: Material requires a way to type the time as well as the dial. Pass a
TimePickerModeToggleas the dialog'smodeToggle, as in Modal time picker, or show the time input alone.
Focus
- Set
autoFocuson the picker to focus the hour when it is shown, as Material advises. - The dialog keeps the focus inside it while it is open, and gives it back to the button that opened it when it closes.
- Tab moves through the hour, the minute, the period selector and the dial, in the order they are written. The period selector is one tab stop, on the selected period. The numbers of the dial are one tab stop too: Tab lands on the first number, at the top of the dial, or on the one last focused, not on the selected one.
- Focusing the hour or the minute selects it, and the dial shows its numbers. Switching to input mode moves the focus to the input of the selection, and the dial cannot be reached while it is hidden.
- The time, the period selector and the dial of a disabled picker cannot be focused. The hour and the minute of a read-only picker can.
Keyboard navigation
| Keys | Actions |
|---|---|
| Tab | Move the focus to the next part of the picker |
| Shift+Tab | Move the focus to the previous part of the picker |
| Up or Down arrow | Step the focused hour or minute, over the dial |
| Left or Right arrow | Move the focus between the hour and the minute over the dial, or to the previous or next number of the dial |
| Arrow keys | Select AM or PM in the period selector |
| Digits | Type the focused hour or minute, and move on to the next once it is full |
| Backspace | Clear the focused hour or minute |
| Space or Enter | Select the focused number of the dial |
| Escape | Close the dialog |
- After the keyboard selects an hour, the dial stays on the hours.
- Set
isKeyboardDismissDisabledon theTimePickerDialogto keep Escape from closing it. - In input mode, the arrow keys move the caret, as in any text input. Enter in the hour moves the focus to the minute, and Enter in the minute submits the form around the picker.
Labeling elements
- Name the picker with an
aria-labeloraria-labelledby. - The picker's title names the dialog. To name it otherwise, set an
aria-labelon theTimePickerDialog. - In picker mode, the hour and the minute are spin buttons named in the locale. In input mode, they are text inputs, as Material advises, named by
hourLabelandminuteLabel, or by the locale's name for the field without a label. Both are marked as required or invalid, and described, as the picker is. - Name the dial with an
aria-labelthat follows the selection, such as Select hour. Its numbers are a group of radio buttons: each is named as the locale counts it, such as 7 hours, and the selected one is checked. - Name the period selector with an
aria-label. It is a group of radio buttons, AM and PM, named as the locale writes them. - Name the mode toggle, an icon button, with an
aria-labelthat follows the display mode, such as Switch to text input mode over the dial.
TimePicker
Does not take minValue, maxValue or granularity.
displayMode'input' | 'picker'Time input pickers allow people to specify a time using keyboard numbers. This input option should be accessible from any other mobile time picker interface by tapping the keyboard icon.
For time selection that doesn’t require a dial view, make a time input picker the default option
layout'horizontal' | 'vertical'The clock dial interface adapts to a device’s orientation. In landscape mode, the stacked input and selection options are positioned side-by-side.
Props of TimePicker (35)
classNameClassNameOrFunction<DateFieldRenderProps>Default'react-aria-TimeField'The CSS className for the element. A function may be provided to compute the class based on component state.
formstringThe
<form>element to associate the input with. The value of this attribute must be the id of a<form>in the same document. See MDN.idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
isDisabledbooleanWhether the input is disabled.
autoFocusbooleanWhether the element should receive focus on render.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
namestringThe name of the input element, used when submitting an HTML form. See MDN.
valuenull | ZonedDateTime | CalendarDateTime | TimeThe current value (controlled).
onChange(value: MappedTimeValue<T> | null) => voidHandler that is called when the value changes.
isReadOnlybooleanWhether the input can be selected but not changed by the user.
isInvalidbooleanWhether the input value is invalid.
defaultValuenull | ZonedDateTime | CalendarDateTime | TimeThe default value (uncontrolled).
isRequiredbooleanWhether user input is required on the input before form submission.
validate(value: MappedTimeValue<T>) => true | ValidationError | null | undefinedA function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if
validationBehavior="native". For realtime validation, use theisInvalidprop instead.placeholderValueZonedDateTime | CalendarDateTime | TimeA placeholder time that influences the format of the placeholder shown when no value is selected. Defaults to 12:00 AM or 00:00 depending on the hour cycle.
hourCycle12 | 24Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale.
hideTimeZonebooleanWhether to hide the time zone abbreviation.
shouldForceLeadingZerosbooleanWhether to always show leading zeros in the hour field. By default, this is determined by the user's locale.
validationBehavior'native' | 'aria'Default'native'Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
styleCSSProperties | (values: DateFieldRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', DateFieldRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<HTMLDivElement>selection'hour' | 'minute'defaultSelection'hour' | 'minute'onSelectionChange(selection: TimePickerSelection) => voidchildrenReactNode | ((values: TimePickerRenderProps) => ReactNode)
TimePicker also takes the 70 attributes and events of the element it renders.
TimePickerDialog
confirmButtonrequiredReactNodeText buttons are used to exit the dialog (Cancel) and save the selector input (OK).
modeToggleReactNodeThe keyboard icon in the lower left toggles between the input picker and the dial picker
Props of TimePickerDialog (21)
classNameClassNameOrFunction<ModalRenderProps>Default'react-aria-ModalOverlay'The CSS className for the element. A function may be provided to compute the class based on component state.
isEnteringbooleanWhether the modal is currently performing an entry animation.
isExitingbooleanWhether the modal is currently performing an exit animation.
onEnter(element: HTMLElement) => void | Promise<void>Callback when the modal starts entering. Return a promise to indicate when the entry animation has completed.
onExit(element: HTMLElement) => void | Promise<void>Callback when the modal starts exiting. Return a promise to indicate when the exit animation has completed.
UNSTABLE_portalContainerdeprecatedElementDefaultdocument.bodyThe container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.
UNSTABLE_deferUntilEnteredbooleanWhether to wait until the entry animation completes before hiding content outside the modal and moving focus into it.
isDismissablebooleanDefaultfalseWhether to close the modal when the user interacts outside it.
isKeyboardDismissDisabledbooleanDefaultfalseWhether pressing the escape key to close the modal should be disabled.
UNSTABLE_overrideFocusbooleanWhether to override the
focus()method so it does not scroll the page. This is temporary and will be removed after fully testing all overlays.shouldCloseOnInteractOutside(element: Element) => booleanWhen user interacts with the argument element outside of the overlay ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the overlay. By default, onClose will always be called on interaction outside the overlay ref.
isOpenbooleanWhether the overlay is open by default (controlled).
defaultOpenbooleanWhether the overlay is open by default (uncontrolled).
onOpenChange(isOpen: boolean) => voidHandler that is called when the overlay's open state changes.
childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
styleCSSProperties | (values: ModalRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', ModalRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.aria-labelstringDefines a string value that labels the current element.
refRef<HTMLDivElement>dismissButtonReactNode
TimePickerDialog also takes the 70 attributes and events of the element it renders.
TimePickerHeader
Takes className, style and children.
TimePickerHeader also takes the 3 attributes and events of the element it renders.
TimePickerContent
Takes className, style and children.
TimePickerContent also takes the 3 attributes and events of the element it renders.
TimePickerInput
hourLabelReactNodeA label below the field
Props of TimePickerInput (1)
minuteLabelReactNode
TimePickerPeriodSelector
Name it with aria-label or aria-labelledby. Its value comes from the picker, so it takes no value props and no children.
Props of TimePickerPeriodSelector (13)
classNameClassNameOrFunction<RadioGroupRenderProps>Default'react-aria-RadioGroup'The CSS className for the element. A function may be provided to compute the class based on component state.
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
aria-errormessagestringIdentifies the element that provides an error message for the object.
styleCSSProperties | (values: RadioGroupRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', RadioGroupRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.
TimePickerPeriodSelector also takes the 70 attributes and events of the element it renders.
TimePickerDial
Name it with aria-label or aria-labelledby. It also takes className and style.
Props of TimePickerDial (2)
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
TimePickerDial also takes the 2 attributes and events of the element it renders.
TimePickerModeToggle
Takes the props of an icon button, except children, and the displayMode it switches from, which selects its icon.
variant'filled' | 'tonal' | 'outlined' | 'standard'Default'standard'There are four icon button color styles, in order of emphasis: filled, tonal, outlined, standard
For the highest emphasis, use the filled style. For the lowest emphasis, use standard.
filled: Use the filled style for visual impact and key actions that require high emphasis. Avoid overusing the filled style on a screen. Use them sparingly.tonal: Use the tonal style as a middle ground between filled and outlined icon buttons. It’s useful for secondary actions paired with a high emphasis action.outlined: Use the outlined style for medium-emphasis buttons. It’s useful when the button isn’t the main focus of the interaction, such as browsing through sets of cards.standard: Use the standard style for low-emphasis buttons, or when placing buttons on a colorful surface.
size's' | 'xs' | 'm' | 'l' | 'xl'Default's'Icon buttons are available in five different sizes:
- Extra small - 32dp
- Small - 40dp (default)
- Medium - 56dp
- Large - 96dp
- Extra large - 136dp
width'narrow' | 'default' | 'wide'Default'default'Three widths: narrow, default, and wide
Container widths in dp:
- XS: narrow 28, default 32, wide 40
- S: narrow 32, default 40, wide 52
- M: narrow 48, default 56, wide 72
- L: narrow 64, default 96, wide 128
- XL: narrow 104, default 136, wide 184
shape'round' | 'square'Default'round'Two shapes: round and square
Corner sizes of a square button: XS 12dp, S 12dp, M 16dp, L 28dp, XL 28dp.
In addition to changing shape when pressed, toggle icon buttons also change the resting shape from round (unselected) to square (selected) by default. If the resting shape is square, the selected shape should be round.
hasShapeMorphbooleanDefaultfalseShape morphs when pressed
While pressed, icon buttons can morph to become more square. Both round and square icon buttons should have the same pressed shape radius.
Corner sizes of the pressed state: XS 8dp, S 8dp, M 12dp, L 16dp, XL 16dp.
aria-labelstringDefines a string value that labels the current element.
isPendingbooleanWhether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.
Props of TimePickerModeToggle (49)
formstringThe
<form>element to associate the button with. The value of this attribute must be the id of a<form>in the same document. See MDN.idstringThe element's unique identifier. See MDN.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
onClick(e: MouseEvent<FocusableElement>) => voidNot recommended – use
onPressinstead.onClickis an alias foronPressprovided for compatibility with other libraries.onPressprovides additional event details for non-mouse interactions.isDisabledbooleanWhether the button is disabled.
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
autoFocusbooleanWhether the element should receive focus on render.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
hrefstringA URL to link to if elementType="a".
targetstringThe target window for the link.
relstringThe relationship between the linked resource and the current page. See MDN.
elementType(props: any) => ReactNode | Promise<ReactNode> | new (props: any, context: any) => Component<any, any, any> | 'button'Default'button'The HTML element or React element used to render the button, e.g. 'div', 'a', or
RouterLink.aria-disabled'true' | 'false' | booleanIndicates whether the element is disabled to users of assistive technology.
aria-expanded'true' | 'false' | booleanIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
aria-haspopup'dialog' | 'menu' | 'true' | 'false' | 'grid' | 'listbox' | 'tree' | booleanIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-controlsstringIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-pressed'true' | 'false' | 'mixed' | booleanIndicates the current "pressed" state of toggle buttons.
aria-current'time' | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | booleanIndicates whether this element represents the current item within a container or set of related elements.
type'button' | 'submit' | 'reset'Default'button'The behavior of the button when used in an HTML form.
preventFocusOnPressbooleanWhether to prevent focus from moving to the button when pressing it.
Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
formActionButtonHTMLAttributes<HTMLButtonElement>['formAction']The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.
formEncTypestringIndicates how to encode the form data that is submitted.
formMethodstringIndicates the HTTP method used to submit the form.
formNoValidatebooleanIndicates that the form is not to be validated when it is submitted.
formTargetstringOverrides the target attribute of the button's form owner.
namestringSubmitted as a pair with the button's value as part of the form data.
valuestringThe value associated with the button's name when it's submitted with the form data.
excludeFromTabOrderbooleanWhether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<HTMLButtonElement & Element>classNameClassNameOrFunction<ButtonRenderProps>styleStyleOrFunction<ButtonRenderProps>isSelecteddefaultSelectedonChangedisplayModerequired'input' | 'picker'