Components

Date Field

Locale-ordered segmented date input with keyboard editing, optional Calendar, validation, paste, and native forms.

DateField splits a date into day, month, and year spinbutton segments. It supports locale order, keyboard stepping, validation, ISO paste, native form submission, and an optional Calendar.

Use Date Field for exact date entry. Set showCalendar to add visual date selection.

Date values come from @internationalized/date. Install it beside Akaza UI when application code creates or transforms dates: pnpm add akaza-ui @internationalized/date.

Anatomy

  • root: Generated date group containing segments and optional calendar trigger.
  • segments: Generated locale-ordered segment wrapper.
  • segment: Generated day, month, or year text input with role="spinbutton".
  • #literal: Optional replacement content for generated separators such as / or ..
  • #calendar-trigger: Optional trigger content with open, close, and toggle actions.
  • calendar content: Generated, positioned role="dialog" containing Calendar when showCalendar is enabled.
  • #calendar: Replaces the built-in Calendar while retaining popup positioning and dismissal.
  • hidden input: Generated native form control carrying the ISO date string and validity.

Date Field generates segment markup to coordinate editing, focus, labels, and spinbutton values. Style segments with ui.segment and state attributes.

Usage

Choose a date from August 10 through August 24.
Not submitted.

Examples

Field integration

Wrap Date Field in Field to inherit its name, label relationship, required state, description, native error message, and granular interaction attributes.

<Field
  label="Start date"
  name="start"
  description="Required for scheduling."
  required
>
  <DateField v-model="date" />
</Field>

Validation stays quiet on initial render. It becomes visible after users leave the group, enter an invalid complete date, or submit its form.

Locale order

locale controls segment order, separators, and segment labels. The model remains an @internationalized/date value.

<DateField v-model="date" locale="en-GB" />

For en-GB, focus order is day, month, year. For en-US, it is month, day, year.

Date constraints

Use boundaries for fixed limits and isDateUnavailable for application rules. Invalid dates expose Field error state after interaction.

<DateField
  v-model="date"
  :min-value="new CalendarDate(2026, 8, 10)"
  :max-value="new CalendarDate(2026, 8, 24)"
  :is-date-unavailable="(date) => closedDates.has(date.toString())"
/>

Calendar picker

Set showCalendar to add a keyboard-accessible calendar trigger. Date Field forwards locale, direction, constraints, disabled state, read-only state, and ui.calendar to its built-in Calendar. Selection commits the date and closes the popup.

<DateField v-model="date" show-calendar>
  <template #calendar-trigger>Calendar</template>
</DateField>

Use v-model:calendar-open when popup state must be controlled. Use #calendar to replace the calendar body without replacing positioning, outside-click dismissal, Escape handling, or layer ordering.

<DateField v-model="date" show-calendar>
  <template #calendar="{ value, select, close }">
    <MyCalendar :value="value" @select="select" @cancel="close" />
  </template>
</DateField>

Paste a date

Paste a date containing three numeric groups into any segment. The component recognizes ISO year-first values such as 2026-11-24 regardless of the visible locale order.

Native form submission

Set name on the component or inherit it from Field. A complete value submits as an ISO calendar date.

<form @submit.prevent="submit">
  <DateField v-model="date" name="start" required />
  <button>Submit</button>
</form>

Cancel changes

value-change fires before the model updates. Canceling restores segment text to the controlled value.

<DateField
  v-model="date"
  @value-change="(next, details) => {
    if (next && blockedDates.has(next.toString())) details.cancel()
  }"
/>

Read-only and disabled

Read-only segments stay focusable for inspection but cannot change. Disabled segments leave the tab sequence and the hidden input is excluded from form submission.

<DateField v-model="date" read-only />
<DateField v-model="date" disabled />

Reactive validation

Changing min/max, required state, unavailable-date predicates, or the controlled value updates native custom validity without requiring another keystroke. Error presentation still follows interaction/submission state. Native reset restores the initial segments unless canceled.

The optional calendar registers as a logical popup branch when used inside an Akaza modal, including when teleported to body.

API Reference

Model

ModelTypeDefaultDescription
v-modelCalendarDateValue | undefinedundefinedComplete date value. Partial segment text is internal until it forms a valid date.
v-model:calendar-openbooleanfalseControls the optional calendar popup.

Props

PropTypeDefaultDescription
idstringgeneratedID assigned to the first locale-ordered segment.
namestringField nameNative form field name.
localestring"en-US"Segment order, separators, and accessible labels.
dir"ltr" | "rtl""ltr"Reading direction and horizontal arrow behavior.
placeholderCalendarDateValuetodayDate context used while segments are empty or partial.
minValueCalendarDateValueEarliest valid complete date.
maxValueCalendarDateValueLatest valid complete date.
isDateUnavailable(date) => booleanMarks complete dates invalid by application rule.
requiredbooleanfalseRequires a complete date for native form validation.
disabledbooleanfalseDisables segments and native form participation.
readOnlybooleanfalseKeeps segments focusable but blocks changes.
invalidbooleanfalseForces invalid styling and ARIA state.
selectOnFocusbooleantrueSelects current segment text when focused.
autoAdvancebooleantrueMoves focus after a segment reaches its maximum length.
showCalendarbooleanfalseAdds a trigger and positioned Calendar popup.
calendarLabelstring"Choose date"Trigger and popup accessible label.
calendarSide"top" | "right" | "bottom" | "left""bottom"Preferred popup side with collision flipping.
calendarAlign"start" | "center" | "end""start"Popup alignment against Date Field.
calendarSideOffsetnumber6Trigger-to-popup gap in pixels.
calendarTeleportstring | false"body"Teleport target; false keeps popup beside Date Field.
ariaLabelstring"Date"Root group label when no external label exists.
ariaLabelledbystringField label IDExternal label relationship.
ariaDescribedbystringField description/error IDsExternal description relationship.
uiDateFieldUiClasses for generated structural parts.

Date Field accepts calendar dates at day granularity. Use Time Field for clock values.

Emits

EventPayloadDescription
update:modelValueCalendarDateValue | undefinedFires after an accepted complete value or clear.
value-change(value, details)Fires before model changes. details.cancel() prevents the change.
value-commit(value, details)Fires after accepted input, keyboard, paste, blur, or clear commits.
update:calendarOpenbooleanFires after accepted calendar popup changes.
calendar-open-change(open, details)Fires before popup changes. details.cancel() prevents the change.

Value details.reason can be input, keyboard, paste, blur, clear, or calendar. Calendar-open reasons include trigger, select, escape, and outside-click.

Slots

SlotPropsDescription
literalvalueReplaces visible locale separator content without changing segment behavior.
calendar-triggerisOpen, open, close, toggleReplaces optional trigger content. Actions accept native event-first handlers.
calendarvalue, select, closeReplaces built-in Calendar content while retaining popup behavior.

Methods

MethodDescription
focus()Focuses the first segment in locale order.
clear(event?)Clears an accepted value and returns whether it changed.
setValue(value, reason, event?)Requests an imperative value change through the normal cancelable event path.
openCalendar(reasonOrEvent?, event?)Opens optional calendar through cancelable lifecycle.
closeCalendar(reasonOrEvent?, event?)Closes optional calendar and restores trigger focus when appropriate.
toggleCalendar(reasonOrEvent?, event?)Toggles optional calendar.

UI Options

KeyDescription
rootDate group root.
segmentsLocale-ordered segment wrapper.
segmentEvery generated day, month, and year input.
literalEvery generated separator.
calendarTriggerOptional calendar button.
calendarContentPositioned calendar popup.
calendarNested CalendarUi object for built-in Calendar parts.
hiddenInputVisually hidden native form input.

Styling Hooks

UI keyCSS classData attrs
rootakaza-date-fielddata-akaza-state="empty|filled", data-akaza-calendar-open, data-akaza-disabled, data-akaza-readonly, data-akaza-required, data-akaza-invalid, data-akaza-dirty, data-akaza-touched, data-akaza-filled, data-akaza-focused
segmentsakaza-date-field-segments
segmentakaza-date-field-segmentdata-akaza-segment="day|month|year", data-akaza-state="empty|filled", data-akaza-placeholder, data-akaza-disabled, data-akaza-readonly, data-akaza-invalid
literalakaza-date-field-literal
calendarTriggerakaza-date-field-calendar-triggerdata-akaza-state="open|closed", data-akaza-disabled, aria-expanded, aria-controls
calendarContentakaza-date-field-calendar-contentdata-akaza-state="open", data-akaza-side, data-akaza-align, floating CSS variables, --akaza-date-field-calendar-duration
hiddenInputakaza-date-field-hidden-input

Plain class applies to the Date Field root. Use ui.segment for generated inputs and data variants for state styling.

Keyboard

KeyBehavior
Number keysEdit the focused segment; full segments can auto-advance.
ArrowUp / ArrowDownIncrement or decrement the focused segment with wrapping.
PageUp / PageDownIncrement or decrement by 10.
Home / EndSet the focused segment to its minimum or maximum.
ArrowLeft / ArrowRightMove focus between locale-ordered segments, direction-aware in RTL.
BackspaceClears native text; from an empty segment, moves to the previous segment.
Enter / Space on calendar triggerOpens or closes Calendar.
Escape in CalendarCloses popup and restores trigger focus.

Each editable part uses role="spinbutton" with aria-valuemin, aria-valuemax, aria-valuenow, and a localized accessible label. Touch users can tap and edit any segment with the numeric keyboard.

Partial segment text remains internal. Date Field updates v-model only after day, month, and year are complete and valid.