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
modelValueCatnipInputDateModelValuenull—Committed value; model-value in HTML / .modelValue in frameworks.
modestring"single"single, rangeSingle date/datetime or range selection.
showTimebooleanfalse—Adds a time input and serializes endpoints as YYYY-MM-DDTHH:mm. Shows the panel action footer.
showPresetsbooleanfalse—Range-only. Shows the preset sidebar (Today, Last 7 days, Custom range, …). Ignored in single mode.
periodPresetsCatnipInputDatePeriodPresetConfig[][]Built-in preset idsSubset, reorder, or relabel built-in range presets. Empty uses the full built-in list.
showActionsbooleanfalse—Forces the panel Reset / Cancel / Apply row. Also shown automatically for showTime and showPresets.
openboolean——Controlled panel state. Pair with open-change.

Date constraints ​

PropTypeDefaultOptionsDescription
minstring""YYYY-MM-DDEarliest selectable date.
maxstring""YYYY-MM-DDLatest selectable date.
disabledDatesstring[][]YYYY-MM-DD valuesSpecific disabled days.
maxRangeDaysnumber—Positive 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 field label when the label slot is empty.
startLabelstring""—Vertical range+time panel: From field label. Defaults to locale From.
endLabelstring""—Vertical range+time panel: To field label. Defaults to locale To.
placeholderstring""—Placeholder for the combined trigger. Empty uses the active display format (YYYY-MM-DD — YYYY-MM-DD in range mode).
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.
panelOrientation"horizontal" | "vertical""horizontal"horizontal, verticalHorizontal pages one month (two side-by-side in range). Vertical stacks a scrollable month list. Range horizontal switches to vertical automatically below 800px.
panelPlacement"top" | "bottom""bottom"top, bottomPreferred panel placement. Flips when there is insufficient space.
panelAlign"start" | "end""start"start, endCross-axis alignment of the panel relative to the trigger.
showClearButtonbooleantrue—Shows an inline reset icon inside the trigger when the field has a value.
clearButtonAriaLabelstring""—Accessible label for the inline reset icon; defaults to bundled inputDate.clear.
supportingTextSupportingTextProp""—One or more helper or validation messages. Each object requires text; intent accepts neutral, danger, warning, or success, and icon accepts a Catnip icon name. See supporting-text examples.
size"s" | "m" | "l""m"s, m, lDimensions and typography.
intent"neutral" | "danger" | "warning" | "success""neutral"neutral, danger, warning, successSemantic state applied to field and supporting-text styling; danger sets aria-invalid on the date control.
disabledbooleanfalse—Disables the trigger, calendar, and panel actions.
readonlybooleanfalse—Prevents editing and panel interaction.
requiredbooleanfalse—Native required state and label marker.
hideLabelbooleanfalse—Hides the built-in label row.
ariaLabelstring""—aria-label when there is no visible label.
ariaDescribedbystring""—Extra id values merged into aria-describedby alongside generated supporting-text ids.

Advanced ​

PropTypeDefaultOptionsDescription
idstring""—DOM id for the input. Auto-generated when omitted.
namestring""—Native name for form submission.
autofocusbooleanfalse—Autofocus on the text input.
optionalbooleanfalse—When true and not required, shows the localized optional hint.
optionalTextstring""—Overrides the localized optional hint (HTML: optional-text).
infostring""—Info tooltip beside the label; when non-empty, it wins over the label.suffix slot.
alignment"left" | "center" | "right""left"left, center, rightHorizontal alignment of the field label block.
requiredMarkerstring"*"—Visual marker for required fields (HTML: required-marker).
requiredScreenReaderTextstring""—Optional screen-reader supplement; it does not replace required on the control (HTML: required-screen-reader-text).
testSelectorsTestSelectorsPropSee Test Selectors—Overrides stable data-test values.

Values ​

Modeshow-timeshow-presetsValue
Singlefalse—"YYYY-MM-DD"
Singletrue—"YYYY-MM-DDTHH:mm"
Rangefalsefalse{ start?: "YYYY-MM-DD"; end?: "YYYY-MM-DD" }
Rangetruefalse{ start?: "YYYY-MM-DDTHH:mm"; end?: "YYYY-MM-DDTHH:mm" }
Range—true{ start?: string; end?: string; preset?: string }

Built-in preset ids: today, yesterday, last-7-days, last-30-days, last-90-days, this-month, last-month, all-time, custom.

Display formats affect only the text shown in the input. Model values, events, constraints, and form serialization continue to use the canonical value formats above. Range endpoints in the trigger are separated with an em dash (—). The trigger fills its container; when the value does not fit on one line it wraps and the field grows in height.

Events ​

NamePayloadDescription
update:modelValuestring | { start?: string; end?: string; preset?: string } | nullCommitted value changed.
open-changebooleanPanel open state changed (true / false). Use @open-change.
submitstring | { start?: string; end?: string; preset?: string }Draft value applied from the panel action row.
cancel—Cancel discarded the draft and closed the panel.
clear—Reset or inline clear reset the value.
close—Panel 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 range mode it also opens a month grid: years on the left and months on the right in the horizontal dual-month panel, or years above months in the vertical stack. Selecting a year updates the month grid; selecting a month returns to the day calendars. Single-date mode still uses the year grid only. In the year grid, arrow keys move between years, PageUp / PageDown move between year ranges, and Enter / Space selects the active year. In the month grid, arrows move between months and Enter / Space selects the active month.

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.
startLabelVertical range+time panel: custom From label; falls back to startLabel prop / locale.
endLabelVertical range+time panel: custom To label; falls back to endLabel prop / locale.
valueSelected-value area inside the default trigger (calendar icon, clear, and chevron stay). Replaces the typeable field.
triggerFull trigger override — see Trigger slot below.

Trigger slot ​

When trigger is set, the default field shell is replaced. The slot is wrapped in an anchor used to position the calendar panel.

  • Include a focusable control (e.g. <button type="button">). Date applies aria-haspopup="grid", aria-expanded, and aria-controls.
  • Click and Enter / Space toggle open/close; ArrowDown opens and moves into the calendar.
  • Prefer the value slot when you only need to customize the selected-date display.
  • If both are set, trigger wins and value is ignored.

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.

Test selectors ​

AttributeDefaultApplies to
rootcatnip-input-dateField wrapper
controlcatnip-input-date-controlCombined wrapping text control
valuecatnip-input-date-valueCustom value slot mount
clearButtoncatnip-input-date-clearInline reset button
chevroncatnip-input-date-chevronTrailing open/close chevron
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
presetscatnip-input-date-presetsRange preset list
presetcatnip-input-date-presetRange preset row
monthcatnip-input-date-monthMonth block in the 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
monthGridcatnip-input-date-month-gridRange month selection grid
monthNamecatnip-input-date-month-nameRange month 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
startLabelcatnip-input-date-start-labelVertical range+time From label
endLabelcatnip-input-date-end-labelVertical range+time To label
actionResetButtoncatnip-input-date-action-resetPanel Reset action button
actionCancelButtoncatnip-input-date-action-cancelPanel Cancel action button
actionSubmitButtoncatnip-input-date-action-submitPanel Apply action button
supportingTextcatnip-input-date-supporting-textSupporting message

Catnip Design System by Signicat