Date Picker
Choose a date from a visual calendar.
<DatePicker aria-label="delivery date" />
Examples
Label
Attach a label to the datepicker using the label
prop.
<DatePicker label="Estimated Delivery Date" />
HelperText
Add additional context as well as display error messages with the helperText
prop.
<DatePicker label="Estimated Delivery Date" helperText="Please select a delivery date." />
Small
A small datepicker is used when vertical spacing is limited.
<DatePicker aria-label="delivery date" size="small" />
Start Icon
Include an icon before the input text.
<DatePicker aria-label="delivery date" startIcon={<Icon icon="search" />} />
Controlled
A datepickers's state can be controlled by a parent React component by setting the value
prop and
passing a handler to the onChange
prop.
Date values are provided using objects in the @internationalized/date package. This library handles correct international date manipulation across calendars, time zones, and other localization concerns.
function Controlled() { const [value, setValue] = React.useState(new CalendarDate(2022, 7, 12)); return <DatePicker aria-label="delivery date" value={value} onChange={setValue} />; }
Unavailable Dates
Set the isDateUnavailable
handler prop to make certain dates unavailable for selection.
function Unavailable() { const { locale } = useLocale(); const isDateUnavailable = React.useCallback((date) => isWeekend(date, locale), [locale]); return <DatePicker aria-label="delivery date" isDateUnavailable={isDateUnavailable} />; }
Disabled State
Set the isDisabled
prop to prevent a user from interacting with the datepicker.
<DatePicker aria-label="delivery date" isDisabled />
Invalid State
Set the validationState
prop to invalid
to render the datepicker in an invalid state.
<DatePicker aria-label="delivery date" helperText="A selection is required" validationState="invalid" />
Props
as?The root element to be rendered