Date Input
Use catnip-input-date when users need a calendar-backed date field, optional time selection, or a start/end date range. 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. Addshow-actionswhen users should explicitly confirm date/time changes. - Range: Use
mode="range"for start/end workflows such as travel dates, reporting windows, and eligibility periods. Each trigger shows a From / To segment label (override withstart-label/end-labelorstartLabel/endLabelslots). An optional grouplabeladds context above both (e.g. "Trip dates"). Default range selection emits after the end date is selected. Addshow-actionswhen users need to review both endpoints before emitting. - Clear: The panel Clear / Submit row is hidden by default; opt in with
show-actions. Setshow-clear-buttonto show a reset icon inside each trigger. Clearing single mode emitsnull; clearing a range trigger emits the remaining range object with that endpoint empty. - 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.
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 for optional group context;startLabel/endLabelprops or slots label each range trigger (From / To by default).label.action/label.suffixmatch Input on the group label only. - 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.
- 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.
- Avoid forcing users to open the calendar for known dates; the field remains typeable for speed.
- Let users change distant years from the month/year header instead of repeatedly stepping month by month. Keyboard users can use Shift + PageUp / Shift + PageDown from the day grid.