CDateInput
CDateInput is a date form field: a CTextField with a CDatePicker calendar in a dropdown menu. It inherits normal field behavior (label, details, clearable, disabled, readonly, rules, validate-on, preset) and adds calendar selection, formatting, locale, typed input, and date bounds.
Basic usage
v-model holds Date | null. The menu opens on focus or ArrowDown and closes on Escape, Tab, outside click, or date pick. With an empty value the calendar opens around today, but today is current, not selected.
Show code
<template>
<c-date-input
v-model="date"
label="Delivery date"
details="Pick a date from the calendar"
preset="input.dateBooking"
clearable
/>
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
const date = shallowRef<Date | null>(null)
</script>Format and locale
format controls the field text, while locale controls the picker language and textual format parts. Locale follows the same contract as CDatePicker: a BCP-47 tag or a partial dictionary override.
Show code
<template>
<c-date-input v-model="date" label="ISO" format="yyyy-MM-dd" />
<c-date-input v-model="date" label="Russian" format="d MMMM yyyy" locale="ru" />
</template>Typed input
The field is read-only by default: dates come from the menu. With typeable, users can type a date manually:
- the model updates only when the full string matches
formatand the date exists; - partial input does not mutate the current
v-model; - typed dates pass the same
disabled-dates,min-date, andmax-datechecks as the calendar; - in
typeablemode arrow keys remain text-editing keys, while mouse picking still works in the menu.
The parser supports numeric tokens: dd, d, MM, M, yyyy, yy.
Show code
<template>
<c-date-input
v-model="date"
label="Departure"
format="dd.MM.yyyy"
details="Use dd.MM.yyyy, weekdays only"
typeable
clearable
:min-date="minDate"
:max-date="maxDate"
:disabled-dates="{ days: [0, 6] }"
/>
</template>Validation and bounds
rules receive the model's Date | null, not the formatted string. min-date, max-date, disabled-dates, and highlighted-dates are forwarded to the picker inside the menu.
Show code
<template>
<c-date-input
v-model="date"
label="Shipping date"
:rules="rules"
validate-on="input"
:min-date="minDate"
:max-date="maxDate"
:disabled-dates="disabledDates"
clearable
/>
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
const date = shallowRef<Date | null>(null)
const minDate = new Date()
const maxDate = new Date(2026, 7, 15)
const disabledDates = { days: [5] }
const rules = [(value?: Date | null) => ({ valid: !!value, message: 'Pick a shipping date' })]
</script>Slots and presets
prepend, append, and details belong to the field. date, week, dates, before-header, before-body, and footer are forwarded to CDatePicker, so the menu can include legends, markers, and footers. An input preset can include a nested datePicker preset to make the field and calendar read as one component.
Show code
<template>
<c-date-input
v-model="launch"
label="Launch date"
format="d MMM yyyy"
preset="input.dateCampaign"
:highlighted-dates="highlightedDates"
clearable
>
<template #prepend>
<c-icon name="fas:bell" source="fa" />
</template>
<template #before-body>
<div>Editorial milestones</div>
</template>
<template #date="{ date, isHighlighted }">
<span>{{ date }} <c-icon v-if="isHighlighted" name="fas:star" source="fa" /></span>
</template>
</c-date-input>
</template>const dateInputCampaign: CInputPreset = {
base: {
field: campaignField,
datePicker: campaignDatePicker,
},
}Keyboard
ArrowDownEscape / TabHome, EndEnter / SpaceFocus stays in the field: keys reach the calendar through the keyboard loop. In typeable mode navigation keys stay with text editing.
API
CDateInput props
modelValueDate | nulltypeablebooleanfalseformatformatstring'dd.MM.yyyy'localestring | Partial<DateLocale>'en'monday-firstbooleanfalsedisabled-datesDisabledDateshighlighted-dates(Date | string)[]min-dateDate | stringmax-dateDate | stringInner field props are available too: label, placeholder, details, no-details, clearable, disabled, readonly, rules, validate-on, preset, and the rest of CInput / CTextField.
Events
update:modelValueDate | nullSlots
prependappenddetails{ errorMessage?: string, details?: string }dateDatePickerDate & { isSelected, isToday }week{ days: DatePickerWeekDay[] }dates{ dates: DatePickerEnrichedDate[], onSelect }before-headerDatePickerSlotApibefore-bodyDatePickerSlotApifooterDatePickerSlotApiPresets
preset is passed to the inner CInput. If its base snapshot contains datePicker, the calendar inside the menu receives it through context.
const booking: CInputPreset = {
base: {
field: bookingField,
menu: bookingMenu,
datePicker: bookingDatePicker,
},
error: {
details: ['text-red'],
},
}CSS classes
c-date-inputCInputc-date-input--typeable