Skip to the content

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 Calendar in range mode in your own popover.
  • The value needs a time as well; InputDate holds 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 a dialog popup; Enter or a click toggles it, Esc closes it.
  • The input renders no label: use Field or pass aria-label.
  • Inside a Modal or Sheet, the calendar portals into that host so it stays interactive.

Properties

See also