Date Input
Used to enter a specific date using segmented keyboard input.
Usage
import { DateInput } from "@chakra-ui/react"<DateInput.Root>
<DateInput.Label />
<DateInput.Control>
<DateInput.SegmentGroup>
<DateInput.Segment />
</DateInput.SegmentGroup>
</DateInput.Control>
<DateInput.HiddenInput />
</DateInput.Root>Shortcuts
The DateInput component also provides convenient shortcuts for common
patterns.
DateInput.Segments
The DateInput.Segments shortcut renders a segment group containing every
segment produced by the current granularity and formatter.
<DateInput.SegmentGroup>
{dateInput.getSegments().map((segment, index) => (
<DateInput.Segment key={index} segment={segment} />
))}
</DateInput.SegmentGroup>This might be more concise if you don't need to customize each segment:
<DateInput.Segments />Date Value
Date values are provided using objects from
@internationalized/date,
which handles timezone-safe, locale-aware date handling.
This will be replaced by the Temporal API when it's widely supported in browsers.
Examples
Sizes
Use the size prop to change the size of the date input.
Variants
Use the variant prop to change the appearance of the date input.
Disabled
Use the disabled prop to prevent user interaction with the date input.
Invalid
Use the invalid prop to indicate that the date input value is invalid.
Read Only
Use the readOnly prop to prevent modification while keeping the value visible.
Controlled
Use the value and onValueChange props to control the date value.
Selected: 2026-01-26
Default Value
Use the defaultValue prop to set an initial date without controlling it.
Min and Max
Use the min and max props to restrict the range of accepted dates.
Leading Zeros
Use the shouldForceLeadingZeros prop to always render two-digit day and month
segments.
Granularity
Use the granularity prop to control which fields are shown. Set it to hour,
minute or second to enter a time alongside the date.
Time Only
Use the granularity and formatter props to compose a time-only input.
Time Zone
A ZonedDateTime value renders a time zone segment. Use hourCycle to switch
between 12 and 24 hour time, and hideTimeZone to hide the segment.
Range
Set the selectionMode prop to "range" to enter a start and end date. Pass
the index prop to DateInput.Segments and DateInput.HiddenInput to target
each date in the range.
Clear Trigger
Combine the useDateInputContext hook with the clearValue method to render a
clear trigger when a value is present.
Date Picker
Compose the date input with the DatePicker component using the useDateInput
hook and the DateInput.RootProvider component. This provides a segmented
keyboard input alongside a calendar trigger.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 1 | 2 | 3 | 4 | 5 |
Jan | Feb | Mar | Apr |
May | Jun | Jul | Aug |
Sep | Oct | Nov | Dec |
2020 | 2021 | 2022 | 2023 |
2024 | 2025 | 2026 | 2027 |
2028 | 2029 |
React Hook Form
Here's an example of integrating with react-hook-form using the Controller
pattern.
Locale
Use the locale prop to change the order and format of the segments.
RTL
Wrap the date input in LocaleProvider to set the locale and text direction
together. Pass dir="rtl" directly to override direction on its own.
Props
Root
| Prop | Default | Type |
|---|---|---|
dir | 'ltr' | 'ltr' | 'rtl'The document's text/writing direction. |
granularity | 'day' | DateGranularityDetermines the smallest unit that is displayed in the date input. |
locale | 'en-US' | stringThe locale (BCP 47 language tag) to use when formatting the date. |
selectionMode | 'single' | SelectionModeThe selection mode of the date input. - `single` - only one date can be entered - `range` - a range of dates can be entered (start and end) |
timeZone | 'UTC' | stringThe time zone to use |
colorPalette | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'The color palette of the component |
size | 'md' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'The size of the component |
variant | 'outline' | 'outline' | 'subtle' | 'flushed'The variant of the component |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | booleanWhether to remove the component's style. | |
allSegments | Partial<{
year: boolean
month: boolean
day: boolean
hour: boolean
minute: boolean
second: boolean
dayPeriod: boolean
era: boolean
literal: boolean
timeZoneName: boolean
weekday: boolean
unknown: boolean
fractionalSecond: boolean
}>The computed segments map for the formatter. | |
createCalendar | (identifier: CalendarIdentifier) => CalendarA function that creates a calendar object for a given calendar identifier. Use this to support non-Gregorian calendars (e.g., Persian, Islamic, Buddhist). | |
defaultPlaceholderValue | DateValueThe initial placeholder date when rendered. | |
defaultValue | DateValue[]The initial selected date(s) when rendered. Use when you don't need to control the selected date(s). | |
disabled | booleanWhether the date input is disabled. | |
form | stringThe `form` attribute of the hidden input element. | |
format | (date: DateValue, details: FormatDateDetails) => stringThe format function for converting a DateValue to a string. | |
formatter | DateFormatterThe date formatter to use. | |
getRootNode | () => ShadowRoot | Node | DocumentA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. | |
hideTimeZone | false | booleanWhether to hide the time zone segment when the value is a `ZonedDateTime`. Has no effect for values without a time zone. |
hourCycle | HourCycleWhether to use 12-hour or 24-hour time format. By default, this is determined by the locale. | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{
root: string
label: (index: number) => string
control: string
segmentGroup: (index: number) => string
hiddenInput: (index: number) => string
}>The ids of the elements in the date input. Useful for composition. | |
invalid | booleanWhether the date input is invalid | |
isDateUnavailable | (date: DateValue, locale: string) => booleanReturns whether a date is unavailable. When a committed date matches, the input is marked as invalid. | |
max | DateValueThe maximum date that can be selected. | |
min | DateValueThe minimum date that can be selected. | |
name | stringThe `name` attribute of the input element. | |
onFocusChange | (details: FocusChangeDetails) => voidA function called when the date input gains or loses focus. | |
onPlaceholderChange | (details: PlaceholderChangeDetails) => voidA function called when the placeholder value changes. | |
onValueChange | (details: ValueChangeDetails) => voidFunction called when the value changes. | |
placeholderValue | DateValueThe controlled placeholder date. | |
readOnly | booleanWhether the date input is read-only. | |
required | booleanWhether the date input is required | |
shouldForceLeadingZeros | false | booleanWhether to always show leading zeros in month, day, and hour fields. When false, formatting follows the locale default (e.g. "1" instead of "01"). |
translations | IntlTranslationsThe localized messages to use. | |
value | DateValue[]The controlled selected date(s). |
RootProvider
| Prop | Default | Type |
|---|---|---|
value * | DateInputApi<PropTypes> | |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Segments
| Prop | Default | Type |
|---|---|---|
index | numberThe index of the date value. Useful when `selectionMode` is `range`. | |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Segment
| Prop | Default | Type |
|---|---|---|
segment * | DateSegment | |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
HiddenInput
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
index | number |