Date Input

A text field for typing a date, with a separate part for the day, month, and year.

mmddyyyy

Usage

Code
import { DateInput } from '@leverui/components';
Code
<DateInput.Root>
  <DateInput.Label />
  <DateInput.Control>
    <DateInput.SegmentGroup>
      <DateInput.Segment />
    </DateInput.SegmentGroup>
  </DateInput.Control>
  <DateInput.HiddenInput />
</DateInput.Root>

Shortcuts

DateInput.Segments

Renders a segment group with every segment the current granularity and formatter produce. These two are the same.

Code
<DateInput.SegmentGroup>
  <For each={dateInput().getSegments()}>{(segment) => <DateInput.Segment segment={segment} />}</For>
</DateInput.SegmentGroup>
Code
<DateInput.Segments />

Date Value

Dates are objects from @internationalized/date. Install it in your app if you call its date constructors. DateInput.DateValue is the accepted date type. Values are arrays, holding one date or a range.

The Temporal API will replace this library once most browsers support it.

Examples

Sizes

Use the size prop to change the size of the date input.

mmddyyyy
mmddyyyy
mmddyyyy
mmddyyyy
mmddyyyy
mmddyyyy
mmddyyyy

Variants

Use the variant prop to change the appearance of the date input.

mmddyyyy
mmddyyyy
mmddyyyy

Disabled

Use the disabled prop to prevent user interaction with the date input.

mmddyyyy

Invalid

Use the invalid prop to indicate that the date input value is invalid.

mmddyyyy

Read Only

Use the readOnly prop to prevent modification while keeping the value visible.

1262026

Controlled

Use the value and onValueChange props to control the date value.

Selected: 2026-01-26

1262026

Default Value

Use the defaultValue prop to set an initial date without controlling it.

1262026

Min and Max

Use the min and max props to restrict the range of accepted dates.

mmddyyyy

Leading Zeros

Use the shouldForceLeadingZeros prop to always render two-digit day and month segments.

01052026

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.

mmddyyyy––––AM

Time Only

Use the granularity and formatter props to compose a time-only input.

––––AM

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.

232026845AMPST

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.

mmddyyyy
mmddyyyy

Clear Trigger

Combine the useDateInputContext hook with the clearValue method to render a clear trigger when a value is present.

1262026

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.

mmddyyyy

Form Integration

Hold the value in Solid signals and validate it on submit, passing value, onValueChange, and invalid to the DateInput.Root.

mmddyyyy

Locale

Use the locale prop to change the order and format of the segments.

ttmmjjjj

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.

يومشهرسنة

Guides

Limits

min and max limit the values you supply, one calendar segment at a time. Keyboard stepping through a segment can still move a complete date past them. For a strict range, validate the date on submit.

Form values

Render one DateInput.HiddenInput per date. They submit values formatted for the locale. shouldForceLeadingZeros pads the month and day in both the segments and the form value. Locale and time zone change both too. To clear both, call useDateInputContext().clearValue() from your own button.

Machine access

Call DateInput.useDateInput and pass the accessor it returns to DateInput.RootProvider. DateInput.PropsProvider sets default props for the roots inside it. They can be reactive. DateInput.Context and useDateInputContext give the nearest date input's machine. LocaleProvider sets the text direction and locale for the date inputs inside it.

Props

Root

PropDefaultTypeDescription
dirltr'ltr' | 'rtl'Text direction.
granularitydayDateGranularitySmallest unit shown.
localeen-USstringLocale for formatting, as a BCP 47 language tag.
selectionModesingleSelectionModesingle for one date. range for a start and an end date.
timeZoneUTCstringTime zone.
colorPalette—stringColor palette, named or your own.
sizemd'2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'Date input size.
variantoutline'outline' | 'subtle' | 'flushed'Date input style.
asdivNative tagHTML tag to render.
asChild—Solid render functionRender your own element with the part's props.
unstyled—booleanTurn off the Lever UI styles.
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 }>Map of the segments the formatter produces.
createCalendar—(identifier: CalendarIdentifier) => CalendarCreate a calendar for an identifier. For non-Gregorian calendars such as Persian, Islamic, or Buddhist.
defaultPlaceholderValue—DateValuePlaceholder date on first render.
defaultValue—DateValue[]Selected date or dates on first render.
disabled—booleanDisable the date input.
form—stringform attribute of the hidden input.
format—(date: DateValue, details: FormatDateDetails) => stringTurn a DateValue into a string.
formatter—DateFormatterDate formatter.
hideTimeZonefalsebooleanHide the time zone segment of a ZonedDateTime value.
hourCycle—HourCycle12-hour or 24-hour time. Default: the locale decides.
id—stringUnique ID for the date input.
ids—Partial<{ root: string label: (index: number) => string control: string segmentGroup: (index: number) => string hiddenInput: (index: number) => string }>Your own IDs for the date input's elements.
invalid—booleanMark the date input as invalid.
isDateUnavailable—(date: DateValue, locale: string) => booleanSay whether a date is unavailable. An unavailable date marks the input invalid.
max—DateValueLatest selectable date.
min—DateValueEarliest selectable date.
name—stringname attribute of the input element.
onFocusChange—(details: FocusChangeDetails) => voidCalled when the date input gains or loses focus.
onPlaceholderChange—(details: PlaceholderChangeDetails) => voidCalled when the placeholder value changes.
onValueChange—(details: ValueChangeDetails) => voidCalled when the value changes.
placeholderValue—DateValuePlaceholder date, when you control it.
readOnly—booleanMake the date input read-only.
required—booleanMark the date input as required.
shouldForceLeadingZerosfalsebooleanAlways show leading zeros in month, day, and hour. When false, the locale decides.
translations—IntlTranslationsTranslated messages.
value—DateValue[]Selected date or dates, when you control them.

RootProvider

PropDefaultTypeDescription
value (required)—DateInputApi<PropTypes>Date input state from useDateInput.
asdivNative tagHTML tag to render.
asChild—Solid render functionRender your own element with the part's props.

Segments

PropDefaultTypeDescription
index—numberIndex of the date value to show, when selectionMode is range.
asdivNative tagHTML tag to render.
asChild—Solid render functionRender your own element with the part's props.

Segment

PropDefaultTypeDescription
segment (required)—DateSegmentPart of the date to show, such as the day, month or year.
asspanNative tagHTML tag to render.
asChild—Solid render functionRender your own element with the part's props.

HiddenInput

PropDefaultTypeDescription
asinputNative tagHTML tag to render.
asChild—Solid render functionRender your own element with the part's props.
index—numberIndex of the date value to submit.
name—stringName submitted with the form.

Customize with CSS

Load the Lever UI stylesheet before your own CSS. size and variant are responsive. Each part has a class, such as .leverui-date-input__segmentGroup. Style the classes or set --leverui-date-input-root-gap, --leverui-date-input-border-color, --leverui-date-input-focus-color, --leverui-date-input-error-color, and --leverui-date-input-segment-focus-background.

Every part accepts class, style, HTML attributes, event handlers, refs, as, and asChild. unstyled on the root or a part turns off its Lever UI styles and keeps its behavior.