Date Input
Use catnip-input-date when users need a calendar-backed date field, optional time selection, a start/end date range, or a range with named presets. For free-form text, use Input. For numeric values, use Number Input.
Behaviour
- Single date: Use the default
mode="single"for one date. Calendar clicks emit immediately whenshow-timeis off; valid typed values commit on Enter or blur. - Date and time: Add
show-timewhen a time matters. Values serialize asYYYY-MM-DDTHH:mm. The panel keeps a draft until Apply; Cancel discards it and Reset clears the draft. - Range: Use
mode="range"for start/end workflows such as travel dates, reporting windows, and eligibility periods. One combined trigger shows both endpoints. Default date-only range selection emits after the end date is selected. - Presets: Add
show-presetson range mode for rolling windows (Today, Last 30 days, This month, and so on). Named presets display their label in the trigger and their dates while the field has focus, so people can check or adjust them; editing the dates, or picking days in the calendar, switches to Custom range. All time keeps its label. Preset selection stays in draft until Apply. - Layout:
panel-orientation="horizontal"pages months (two months for range). Below 800px, range horizontal panels use the stacked vertical layout instead.verticalis always a stacked, scrollable month list.panel-placementandpanel-aligncontrol where the panel opens relative to the trigger; it still flips when space is tight. When the field shows supporting text, the panel opens below it so error messages stay visible. Give the field the width you can spare: the value stays on one line and scrolls inside the field when it doesn't fit. A date-time range needs about 400px to show in full. Withshow-presets, the preset list is a full-height left column; Reset / Cancel / Apply sit under the calendars only. - Clear: The inline clear control is shown by default when the field has a value. The panel Reset / Cancel / Apply row appears for
show-time,show-presets, or an explicitshow-actions. Clearing single mode emitsnull; clearing a range emits an empty range object. - Typing: Accept and store canonical strings. Use
display-formatfor visible text layouts and placeholders such asDD/MM/YYYYonly as hints; do not rely on placeholder text instead of a visible label. The field announces its format to screen readers, and also accepts other separators, missing leading zeros, digits without separators, and month names (useful for voice input), rewriting the date in the display format on blur. Text that doesn't parse stays in the field and is flagged on blur with a format message instead of being reverted or committed. Time boxes accept only digits and:, and expand shorthand such as930to09:30. On phones, a single date with an all-digitdisplay-formatbrings up a number pad. - Opening: The calendar opens on click or Arrow Down, never on focus alone, so keyboard users tabbing through a form aren't interrupted by a panel covering the next fields. Tab from the field closes it.
Constraints
- Bounds: Set
minandmaxwhen users must stay inside a known window. - Disabled dates: Use
disabled-datesfor specific unavailable days, e.g. holidays or maintenance windows. - Range length: Use
max-range-daysto cap range selections by inclusive calendar days, e.g.max-range-days="7"allows the start date plus the next six days. - Week start: Use
first-day-of-weekto match regional expectations. The default is1(Monday). - Locale: Set
localefor month and weekday labels when the app locale differs from the browser context.
Composition
- Labels:
labelprop orlabelslot above the single trigger.startLabel/endLabelprops or slots label the From / To datetime fields in the vertical range+time panel.label.action/label.suffixmatch Input on the group label only. - Custom value:
slot="value"replaces the typeable date text inside the default trigger (icon, clear, and chevron remain). The field is no longer typed — selection still goes through the calendar. - Custom trigger:
slot="trigger"replaces the whole field shell. Include a focusable control; click toggles the panel, and Enter / Space / Arrow Down open it with focus inside. Use this only when you need a non-field control (e.g. a button). - Supporting text: Pass
supporting-texton the host. Do not mountFieldSupportingTextmanually. - Status:
intentfollows the shared field model:neutral,warning,danger, andsuccess.
Best practices
- Prefer date-only mode unless the user truly needs a time.
- Use range mode only when both endpoints belong to the same decision.
- Use
show-presetsfor reporting windows and similar “last N days” choices; keep plain range when the user is picking two specific dates. - Match the display format to the product locale or workflow while keeping submitted values canonical for APIs and storage.
- Keep disabled dates explainable in nearby supporting text when the reason is not obvious. Screen reader users hear them as unavailable, but not why.
- Avoid forcing users to open the calendar for known dates; the field remains typeable unless you use
slot="value"orslot="trigger". - Let users jump by month and year from the header instead of repeatedly stepping month by month. In range mode the header shows years and months together. Keyboard users can also use Shift + PageUp / Shift + PageDown from the day grid.