Date Input
The catnip-input-date custom element lets users type or pick a single date, date and time, or date range from a floating calendar panel. It uses the same integrated label and supporting-text patterns as Input, Number Input, and Chip Input. Shared field behaviour is summarised on Inputs overview.
Overview
catnip-input-date values are canonical date strings, not UTC timestamps. Single-date values must use YYYY-MM-DD. Date-time values use YYYY-MM-DDTHH:mm without a timezone suffix, so they represent the selected calendar date and time rather than a converted UTC instant. Use display-format only to change the visible text in the input.
- Single date (
v-model):model-value/.modelValueis a string inYYYY-MM-DDformat. Calendar selection commits immediately whenshow-timeis off. - Date and time: Set
show-timeto commitYYYY-MM-DDTHH:mm. Values commit as the selected date/time becomes valid; setshow-actionswhen users should confirm with Submit. - Range: Set
mode="range"to bind{ start?: string; end?: string }. By default, range emits after the end date is selected; setshow-actionsfor draft selection with Clear / Submit. - Display format: Set
display-formatanddisplay-date-time-formatwith Day.js-style format tokens to change visible input text only. Emitted values stay canonical. - Inline clear: Set
show-clear-buttonto show a reset icon inside the trigger, immediately before the calendar icon. - Constraints: Use
min,max, anddisabled-datesto block invalid calendar cells. In range mode, usemax-range-daysto cap the inclusive number of calendar days between start and end. - Calendar: The panel has month navigation, a clickable month/year header for year selection, weekday headers, current/selected/range states, and keyboard navigation for day movement.
Live example
Accessibility
- Label: Use the
labelprop orlabelslot;for/idwiring is handled automatically. - Trigger: The native text input exposes
aria-haspopup="grid",aria-expanded, and panel linkage while open. - Calendar: Arrow keys move by day/week, Home / End move within the week, PageUp / PageDown change month, Shift + PageUp / Shift + PageDown change year, Enter / Space select, and Escape closes.
- Invalid state:
intent="danger"setsaria-invalid="true"on the control;aria-describedbyincludes supporting text when present.