InputDate
InputDate is a date field: an Input that opens a Calendar popover.
The value is always an ISO yyyy-MM-dd string; only the display follows displayFormat and locale. It is
controlled only: users change the date through the calendar, not by typing.Forms
When to use
Use when
- Collecting a single date in a form.
- Some dates must be blocked (weekends, past days) or bounded by
minDate/maxDate.
Avoid when
- The value is a date range — use
Calendarinrangemode in your own popover. - The value needs a time as well;
InputDateholds a date only.
Usage
const [date, setDate] = useState('2024-05-10');
<InputDate aria-label="Start date" value={date} onValueChange={setDate} />;onValueChange receives the ISO string. onChange receives a synthetic event whose target.value is the same ISO
string — the shape Field and Form consume. There is no defaultValue: seed state with
an ISO string.
Format and locale
The display defaults to dd/MM/yyyy with the ptBR locale. Pass a date-fns locale and format for other markets:
displayFormat="MM/dd/yyyy"
import { enUS } from 'date-fns/locale';
<InputDate value={date} onValueChange={setDate} locale={enUS} displayFormat="MM/dd/yyyy" />;Restrictions
Weekends disabled
<InputDate value={date} onValueChange={setDate} minDate={new Date()} />
<InputDate value={date} onValueChange={setDate} disabledDates={{ dayOfWeek: [0, 6] }} />minDate and maxDate are inclusive bounds and also limit the month and year dropdowns. disabledDates takes any
react-day-picker matcher. The popover scales in and fades out (motion, default scale); motion="none" opts out.
Accessibility
- The input has
role="combobox"and opens adialogpopup;Enteror a click toggles it,Esccloses it. - The input renders no label: use
Fieldor passaria-label. - Inside a
ModalorSheet, the calendar portals into that host so it stays interactive.
Properties
Name
Type
Default
Description
clearablebooleannoneShows a clear button ("×" icon) when there is a value. Requires `reset`
to work outside a `Form`.
clearLabelstring'Limpar'Accessible name of the clear button (`clearable`) — it shows only an icon.
disabledDatesMatcherMatcher[]noneRestriction of dates that cannot be selected. Accepts the
`react-day-picker` `Matcher` (Date, DateRange, function, or array).
displayFormatstring'dd/MM/yyyy'`date-fns` format used to display the date in the input. Does not affect
the `value` (which stays ISO).
iconanynoneReact element rendered inside the input (usually an `<Icon />`).
When set, the input automatically makes room to avoid collision
with the typed text.
@example ```tsx
<Input icon={<Icon icon={search} />} iconPosition="left" />
```
iconPosition"right""left"'right'Side on which the icon (`icon` or the clear button) is rendered.
localeLocaleptBR`date-fns` locale used by the calendar and by the display formatting.
maxDateDatenoneMaximum selection bound (inclusive). Shortcut for
`disabledDates={{ after: maxDate }}`.
minDateDatenoneMinimum selection bound (inclusive). Shortcut for
`disabledDates={{ before: minDate }}`.
motion"fade""scale""slide-up""slide-down""slide-left""slide-right""collapse""sheet""sheet-top""drawer-left""drawer-right""push-left""push-right""none"'scale'Enter/exit animation of the calendar popover.
The default `scale` grows the popover out of the input on open
(`@starting-style`) and fades it back out on close — it stays mounted
until the exit finishes (`useExitTransition`). `prefers-reduced-motion`
zeroes it centrally. Set `motion="none"` for an instant open/close. Same
prop and vocabulary as `Dropdown`.
onChange((event: ChangeEvent<HTMLInputElement, Element>) => void)noneCallback compatible with the native `<input>` signature. Receives a
synthetic event whose `target.value` is the selected ISO `yyyy-MM-dd`.
Kept for drop-in compatibility with `react-hook-form`, `Field`, and
existing consumers.
onValueChange((isoString: string) => void)noneOptional callback with the clean signature. Receives the ISO string
directly. Preferred in new code that does not need the synthetic event
shape.
reset(() => void)noneCallback invoked when the user clicks the clear button (`clearable`).
Inside a `Form`, it is injected automatically; in standalone use, it
must clear the controlled state.
size"expansive""medium""compact""micro"'medium'Size token of the input.
valuestringnoneCurrently selected date, in ISO `yyyy-MM-dd`.
When `undefined`, the input is empty and the calendar opens on the
current month. When filled, the calendar opens on the value's month.
variant"default""success""error"'default'Visual variant of the input — reflects the validation state.