Date
A unified date input supporting inline calendars, single-date popovers, and two-month range pickers with presets and comparisons.
import { DateInput } from '@uthereal/ui/date-input'Date input playground
Overview
DateInput unifies inline month calendars, single-date fields, and multi-month range pickers behind one schema and shared calendar core. Choose mode to mount the calendar inside a popover or directly on the page, and choose selectionMode for one date, a start-to-end range, or multiple dates. All modes store and emit ISO 8601 date strings (YYYY-MM-DD) owned by the host.
mode | selectionMode | Default months | Default commitMode | Best for |
|---|---|---|---|---|
popover | single | 1 | immediate | Form fields such as due dates, deadlines, and birth dates. |
popover | range | 2 (1 below 712px) | apply | Bookings, filters, and reporting windows with presets. |
inline | single | 1 | immediate | Always-visible booking panels and dashboard date selectors. |
inline | range | 1 (or explicit 2) | immediate | Embedded itinerary or reservation calendars inside a card. |
inline | multiple | 1 (or explicit 2) | immediate | Picking several non-contiguous dates with maxSelectedDates. |
Use DateInput for calendar dates and date ranges. Enable allowTyping in popover mode when users type known dates from memory.
Usage
'use client'
import { useState } from 'react'
import { DateInput } from '@uthereal/ui/date-input'
export function LaunchDate() {
const [dates, setDates] = useState<string[]>([])
return (
<DateInput
label="Launch date"
min="2026-01-01"
value={dates}
onValueChange={setDates}
/>
)
}value and onValueChange always use ISO date arrays ([date] for single, [start, end] for range, and a list for multiple). In range mode with compare, control the comparison rule independently with comparison and onComparisonChange, or compute the matching period on the server with comparisonRange.
Examples
Inline calendar
Set mode="inline" to render the calendar grid directly on the page without a trigger or popover. Use variant="ghost" for a bare grid inside a card, showToday for a header jump pill, or selectionMode="multiple" with disabledWeekdays and maxSelectedDates for availability pickers.
Range picker
Set selectionMode="range" and defaultPresets for a popover that shows two months beside a vertical preset rail at 712px or wider, and collapses to one month under a scrolling preset row on narrow viewports. Selections stay in a draft state until the user selects Apply; Cancel, Escape, or outside clicks discard the draft.
Reporting comparison
Combine selectionMode="range", compare, and an explicit today reference date for deterministic reporting windows. Setting today seeds standard reporting presets, bounds the range end when max is omitted, and renders comparison bands for previous-period (equal inclusive day count) or previous-year (leap-day clamped).
vs. Aug 23 – Sep 21, 2026
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Date" | Visible label and accessible name. Name the information asked for, in sentence case. |
hideLabel | booleanDefault: false | Hide the label visually when the context already names the field. It is still announced. |
description | string— | Supporting text below the field, announced with it. Use it for format hints and constraints. |
error | string— | Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely. |
required | booleanDefault: false | Marks the field as required for assistive technology and shows an indicator. Your application validates the value. |
readOnly | booleanDefault: false | The value can be focused, selected, and copied, but not edited. It is still submitted with a form. |
disabled | booleanDefault: false | Unavailable and removed from the tab order. A disabled field is not submitted with a form. |
name | string— | Native form field name, submitted with the value in a form. |
mode | popover | inlineDefault: "popover" | popover renders a trigger field that opens a calendar panel; inline renders the calendar grid directly on the page. |
selectionMode | single | range | multipleDefault: "single" | single picks one date; range picks a start and end date with stretching week highlights; multiple toggles separate dates (inline mode only). |
months | 'auto' | 1 | 2Default: "auto" | Number of visible months: auto renders 2 months beside a vertical preset rail in wide range popovers (>= 712px) and 1 month otherwise. |
commitMode | immediate | apply— | immediate commits on day selection; apply stages a draft with Cancel and Apply actions. Omitted defaults to apply in popover range mode and immediate otherwise. |
defaultValue | string | string[]— | Initial ISO date ("2026-10-17"), [start, end] tuple for range, or list of dates for multiple. Later edits do not reset a mounted instance. |
maxSelectedDates | integer— | Maximum selectable dates when selectionMode is multiple; omitted allows any number up to 366. |
today | string— | Host reference ISO date for deterministic reporting presets and default range bounds. |
min | string— | Earliest selectable ISO date. Earlier days are disabled in the calendar. |
max | string— | Latest selectable ISO date. Later days are disabled in the calendar. |
locale | string— | BCP 47 locale for date order, month/weekday names, and first weekday. Omit to inherit UtherealProvider locale or en-US. |
startOfWeek | integer— | First weekday column: 0 Sunday through 6 Saturday. Omit to follow locale. |
disabledDates | string[]Default: [] | Unavailable ISO dates (e.g. holidays), displayed struck through and skipped by selection. |
disabledWeekdays | number[]Default: [] | Unavailable weekdays, 0 Sunday through 6 Saturday (e.g. [0, 6] for weekends). |
presets | DatePreset[]Default: [] | Shortcuts beside the calendar. Each value matches the mode shape using fixed ISO dates or relative objects ({ unit, offset, edge }). |
defaultPresets | booleanDefault: false | Populate standard relative presets (Today, Yesterday, Last 7/30/90 days, This/Last month, This quarter, Year to date) in range mode when presets is empty. |
compare | booleanDefault: false | Offer previous-period and previous-year comparison options in range mode. |
defaultComparison | off | previous-period | previous-yearDefault: "off" | Initial comparison rule in range mode; existing host state survives edits. |
allowTyping | booleanDefault: false | Popover mode only: render locale-formatted date input(s) alongside a calendar trigger button instead of a single button trigger. |
showToday | booleanDefault: false | Show a Today button in the calendar header that jumps to the current month. |
defaultOpen | booleanDefault: false | Initial popover visibility in popover mode; use open and onOpenChange for controlled state. |
placeholder | stringDefault: "Select a date" | Shown in the trigger button or empty input when no date is selected. |
placement | PlacementDefault: "bottom-start" | Preferred popover side and alignment; flips automatically to stay within the viewport. |
variant | outline | soft | ghostDefault: "outline" | Field surface in popover mode (outline, soft, ghost), or panel framing in inline mode (outline bordered, soft filled, ghost bare). |
size | sm | md | lgDefault: "md" | Field height and text scale: 36, 44, or 50 pixels. |
labels | DateInputLabels— | Translatable text and accessible names for navigation, presets, footer status, Apply/Cancel, and comparison options. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve identical interaction behavior. |
theme | DateInputTheme— | Color mode, accent, and semantic design tokens. See Theming for all keys and defaults. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset for popover entrance, rolling date text, sliding months, and stretching range highlights. none and system reduced motion disable travel. |
motionOptions | DateInputMotionOptions— | Calendar popup transition, entrance, and exit overrides (durations in milliseconds). |
dir | ltr | rtl— | Reading direction. Omit to inherit page direction. |
React integration
| Prop | Purpose |
|---|---|
value, onValueChange | Controlled ISO date array and commit callback (string[]). |
comparison, onComparisonChange | Controlled reporting comparison rule ('off' | 'previous-period' | 'previous-year'). |
open, onOpenChange | Controlled popover visibility (mode="popover"). |
boundary | Function returning a bounding element for responsive 1- vs 2-month measurement. |
renderIcon(name, context) | Custom icon renderer; slot is 'trigger', 'previous', 'next', or 'preset'. |
portalContainer | Custom portal target, e.g. an element inside a native modal dialog top layer. |
ref | Trigger button, first typed input (allowTyping), or inline calendar root. |
preset | Application defaults (locale, labels, startOfWeek), overridden by props. |
tokens | CSS custom properties applied after the typed theme on root and portal. |
className, style | Applied to the root field element. |
| Native attributes | Forwarded to the trigger, first typed input, or inline container. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves through the trigger (or inputs), preset rail, header controls, grid, footer. |
Enter, Space, ArrowDown | On the closed trigger: opens the calendar popover. |
| Arrow keys | Moves day by day or week by week across months; follows dir. |
Home, End | Moves to the start or end of the current week. |
PageUp, PageDown | Moves by one month (Shift + PageUp/PageDown moves by one year). |
Enter, Space | Selects the focused day, preset, month, year, or comparison option. |
ArrowUp/Down or Left/Right | Cycles focus inside the preset rail and comparison role="radiogroup". |
Escape | Closes the popover, discards any staged draft, and returns focus to the trigger. |
The trigger exposes aria-haspopup="dialog", aria-expanded, and a combined accessible name from the label and formatted value (or placeholder). The popover renders role="dialog" with a polite role="status" live region announcing range progress and visible months. Every calendar grid exposes role="grid", aria-selected, aria-current="date", and aria-disabled on unavailable or out-of-bounds days so keyboard navigation stays continuous. All layouts mirror in dir="rtl" and preserve borders, active ranges, and focus outlines in forced-colors: active.
Motion and theming
- Popover entrance: grows
8pxfrom the calendar icon at scale0.95on the snappy spring and exits in140ms. - Rolling date text: changed date parts roll up for later dates and down for earlier dates while unchanged parts shift smoothly with
layout="position". - Single and multiple grids: months slide on a retargetable zero-bounce strip and the single-date selection disc glides across cells.
- Range grids: per-week highlight bars stretch along the logical inline axis (
0.42s, bounce0), start and end caps glide between days, and keyboard navigation snaps highlights immediately without lag. - Preset and comparison highlights: active pills glide on a critically damped spring (
0.42s, bounce0). - Reduced motion:
prefers-reduced-motion: reducereplaces travel and springs with120msopacity crossfades;motion="none"makes all updates immediate (0ms).
theme accepts the core and control token groups, plus borderStrong, borderSubtle, surfaceSunken, accentStrong, accentSubtle, radiusSm, popupRadius, popupPadding, surfaceRadius, shadowResting, and the component token padding (--ui-date-input-padding).
Composition
DateInput is a leaf component. Its ISO date array is host state at /fields/instance-<id>/value, and its comparison rule is host state at /fields/instance-<id>/comparison. Stored values survive configuration edits while they remain valid for the active selectionMode, min, max, and maxSelectedDates.
{
"type": "DateInput",
"props": {
"label": "Reporting period",
"selectionMode": "range",
"today": "2026-10-21",
"defaultPresets": true,
"compare": true,
"defaultComparison": "previous-period"
},
"children": []
}