Back to Onyx

InputDatePicker

web/lib/opal/src/components/inputs/input-date-picker/README.md

4.4.01.5 KB
Original Source

InputDatePicker

Import: import { InputDatePicker } from "@opal/components";

Segmented date field on the shared .opal-input chrome, the Figma Input/Date. Mono MM/DD/YYYY segments accept typed input (auto-advance, backspace to the previous segment, commit on blur or Enter once the segments form a real in-range date), and the calendar action opens the Opal Calendar in a popover for click selection. Invalid or out-of-range typing reverts to the committed value.

tsx
<InputDatePicker
  value={date}
  onChange={setDate}
  maxDate={new Date()}
  clearable
/>

Props

PropTypeDefaultDescription
valueDate | nullSelected date (required, controlled)
onChange(date: Date | null) => voidFires on commit, null when cleared
errorbooleanfalseError chrome on the field
disabledbooleanfalseDisabled chrome, segments and calendar action inert, clear action hidden
clearablebooleanfalseShows a clear action while a value is set and the field is enabled
minDateDateEarliest selectable day (inclusive)
maxDateDateLatest selectable day (inclusive)
idstringApplied to the month segment for <label htmlFor>

Date ranges (the Figma Range variant) are not implemented yet. The Calendar beneath already supports mode="range", so a range picker is an API addition here, not a new surface.