Skip to content

Date Input

Shared label and supporting-text behaviour with catnip-input is summarised on Inputs overview.

catnip-input-date

Props

Value & mode

PropTypeDefaultOptionsDescription
modelValuestring | { start?: string; end?: string } | nullnullCommitted value; model-value in HTML / .modelValue in frameworks.
modestring"single"single, rangeSingle date/datetime or range selection.
showTimebooleanfalseAdds a time input and serializes endpoints as YYYY-MM-DDTHH:mm.
showActionsbooleanfalseShows the panel Clear / Submit row. When false, valid selections commit automatically.
openbooleanControlled panel state. Use with update:open.

Date constraints

PropTypeDefaultOptionsDescription
minstring""YYYY-MM-DDEarliest selectable date.
maxstring""YYYY-MM-DDLatest selectable date.
disabledDatesstring[][]YYYY-MM-DD valuesSpecific disabled days.
maxRangeDaysnumberPositive integerRange-only inclusive maximum number of calendar days. 0 / unset means no range-length limit.
firstDayOfWeeknumber10 through 6First day in the calendar grid; 0 is Sunday, 1 is Monday.
localestring""BCP 47 localeLocale for month and weekday labels. Empty uses the browser locale.

Field presentation

PropTypeDefaultOptionsDescription
labelstring""Visible label text when the label slot is empty.
startLabelstring""Range mode: label above the start trigger. Defaults to locale From.
endLabelstring""Range mode: label above the end trigger. Defaults to locale To.
placeholderstring""Placeholder for the typed date value. In range mode, applies to the start trigger only; the end trigger uses a lowercased display-format hint.
displayFormatstring"YYYY-MM-DD"Day.js format tokensVisible date-only input format. Parsing also accepts this format; emitted values stay canonical.
displayDateTimeFormatstring"YYYY-MM-DD HH:mm"Day.js format tokensVisible datetime input format when the typed value includes time. Parsing also accepts this format; emitted values stay canonical.
showClearButtonbooleanfalseShows an inline reset icon inside the trigger, immediately before the calendar icon.
clearButtonAriaLabelstring""Accessible label for the inline reset icon; defaults to bundled inputDate.clear.
supportingTextstring | string[] | { text, intent?, icon? } | { text, intent?, icon? }[]""Message(s) below the field. See Inputs overview — Multiple supporting messages.
sizestring"m"s, m, lDimensions and typography.
intentstring"neutral"neutral, warning, danger, successStatus styling; danger sets aria-invalid.
disabledbooleanfalseDisables the trigger, calendar button, and panel actions.
readonlybooleanfalsePrevents editing and panel interaction.
requiredbooleanfalseNative required state and label marker.
hideLabelbooleanfalseHides the built-in label row.
ariaLabelstring""aria-label when there is no visible label.
ariaDescribedbystring""Extra id values merged into aria-describedby.

Advanced

PropTypeDefaultOptionsDescription
idstring""DOM id for the input. Auto-generated when omitted.
namestring""Native name for form submission. Range mode submits start/end controls as ${name}-start and ${name}-end.
autofocusbooleanfalseAutofocus on the first text input.
optionalbooleanfalseShows optional hint on the label when not required.
optionalTextstring""Overrides optional hint text.
infostring""Info tooltip on the label.
alignmentstring"left"left, center, rightLabel alignment.
requiredMarkerstring"*"Visual required marker.
requiredScreenReaderTextstring""Supplemental screen-reader text for required fields.
testSelectorsobjectSee Test SelectorsOverrides for data-test.

Values

Modeshow-timeValue
Singlefalse"YYYY-MM-DD"
Singletrue"YYYY-MM-DDTHH:mm"
Rangefalse{ start?: "YYYY-MM-DD"; end?: "YYYY-MM-DD" }
Rangetrue{ start?: "YYYY-MM-DDTHH:mm"; end?: "YYYY-MM-DDTHH:mm" }

Display formats affect only the text shown in the input controls. Model values, events, constraints, and form serialization continue to use the canonical value formats above.

Events

NamePayloadDescription
update:modelValuestring | { start?: string; end?: string } | nullCommitted value changed.
update:openbooleanPanel open state changed.
submitstring | { start?: string; end?: string }Draft value submitted from the panel action row when showActions is true.
clearClear action reset the value.
closePanel dismissed.

Keyboard

KeyBehaviour
Arrow Left / RightMove active day backward / forward.
Arrow Up / DownMove active day by one week.
Home / EndMove to the start / end of the active week.
PageUp / PageDownMove to the previous / next month.
Shift + PageUp / Shift + PageDownMove to the same month in the previous / next year.
Enter / SpaceSelect active date.
EscapeClose the panel.

The month/year header button opens a year grid. In the year grid, arrow keys move between years, PageUp / PageDown move between year ranges, and Enter / Space selects the active year.

Slots

NameDescription
labelCustom label content; falls back to label prop.
label.actionTrailing action in the label row.
label.suffixCustom label suffix; used only when info is empty.
startLabelRange mode: custom label above the start trigger; falls back to startLabel prop / locale.
endLabelRange mode: custom label above the end trigger; falls back to endLabel prop / locale.

Forms

The name you set on <catnip-input-date> participates in form serialization. Single mode submits the committed string value. Range mode serializes the committed object as JSON for form-associated custom element submission; the visible range text inputs also use ${name}-start and ${name}-end for progressive form compatibility.

Test selectors

AttributeDefaultApplies to
rootcatnip-input-dateField wrapper
controlcatnip-input-date-controlSingle-date text input
startControlcatnip-input-date-start-controlRange start text input
endControlcatnip-input-date-end-controlRange end text input
startLabelcatnip-input-date-start-labelRange start segment label
endLabelcatnip-input-date-end-labelRange end segment label
clearButtoncatnip-input-date-clearSingle-date inline reset button
startClearButtoncatnip-input-date-start-clearRange start inline reset button
endClearButtoncatnip-input-date-end-clearRange end inline reset button
singleCalendarButtoncatnip-input-date-calendar-buttonSingle-date calendar trigger button
startCalendarButtoncatnip-input-date-start-calendar-buttonRange start calendar trigger button
endCalendarButtoncatnip-input-date-end-calendar-buttonRange end calendar trigger button
previousButtoncatnip-input-date-previousPrevious month / year-range button
nextButtoncatnip-input-date-nextNext month / year-range button
viewTogglecatnip-input-date-view-toggleMonth/year header toggle
panelcatnip-input-date-panelFloating calendar panel
gridcatnip-input-date-gridCalendar grid
daycatnip-input-date-dayCalendar day button
yearGridcatnip-input-date-year-gridYear selection grid
yearcatnip-input-date-yearYear selection button
timecatnip-input-date-timeOptional time section
singleTimeInputcatnip-input-date-time-inputSingle-date time input
startTimeInputcatnip-input-date-start-time-inputRange start time input
endTimeInputcatnip-input-date-end-time-inputRange end time input
actionClearButtoncatnip-input-date-action-clearPanel Clear action button
actionSubmitButtoncatnip-input-date-action-submitPanel Submit action button
supportingTextcatnip-input-date-supporting-textSupporting message

Catnip Design System by Signicat