Skip to content

Date Range Field

Enter start and end dates in separate editable fields.

Demos

Size
Variant

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Typing and calendar selection

Set :show-calendar="false" for a typing-only range. Bind v-model:calendar-open to control calendar visibility.

Click a date segment to type or use the calendar button to choose a date. Focus and text selection use the neutral secondary fill with its paired foreground. A subtle ring marks the active segment. Slashes have their own spacing. The calendar opens outside the preview frame and follows the same size as the field.

Installation

Complete the shared installation. Copy DateRangeField.vue and index.ts into app/components/ui/date-range-field/. Also copy the required components: Calendar, Date Field.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantoutline, soft, bareoutline

See Range selection for preview fills and primary-colored endpoints.

Props

PropTypeDefaultDescription
rangeColor"secondary" | "accent""secondary"Preview and committed middle fill; endpoints use primary.
calendarLabelstring"Choose date range"Accessible label for the calendar button and popup.
showCalendarbooleantrueOffer a range calendar alongside segmented typing.
calendarOpenbooleanfalseCalendar visibility, also available as v-model:calendar-open.
idstringField/generated idID assigned to the first start segment.
namestringField nameBase native form name used to create .start and .end names.
startNamestring${name}.startExplicit start form field name.
endNamestring${name}.endExplicit end form field name.
localestring"en-US"Segment order, separators, and accessible labels for both endpoints.
dir"ltr" | "rtl""ltr"Reading direction and segment arrow behavior.
placeholderCalendarDateValuetodayDate context used while endpoint segments are partial.
minValueCalendarDateValue-Earliest valid start and endpoint value.
maxValueCalendarDateValue-Latest valid end and endpoint value.
isDateUnavailable(date) => boolean-Application rule for unavailable dates.
allowNonContiguousRangesbooleanfalseAllows unavailable dates inside, but not at boundaries.
maximumDaysnumber-Maximum inclusive range length.
fixedDate"start" | "end"-Makes one endpoint read-only.
requiredbooleanfalseRequires both endpoints for native validity.
disabledbooleanfalseDisables editing and native form participation.
readOnlybooleanfalseKeeps segments focusable but blocks changes.
invalidbooleanfalseForces invalid styling and ARIA state.
selectOnFocusbooleantrueSelects focused segment text.
autoAdvancebooleantrueAdvances after a segment reaches full length.
startLabelstring"Start date"Accessible label for the start Date Field.
endLabelstring"End date"Accessible label for the end Date Field.
ariaLabelstring"Date range"Root group label without an external label.
ariaLabelledbystringField label IDExternal label relationship.
ariaDescribedbystringField description/error IDsExternal description relationship.
uiDateRangeFieldUi-Classes for generated structural parts.

Slots

SlotPropsDescription
start-literalvalueReplaces locale separators inside the start endpoint.
separator-Replaces the visual separator between endpoints.
end-literalvalueReplaces locale separators inside the end endpoint.

Events

EventPayloadDescription
update:modelValueCalendarDateRangeFires after an accepted endpoint change or clear.
value-change(range, details)Fires before model changes. details.cancel() prevents the change.
value-commit(range, details)Fires after accepted endpoint input, keyboard, paste, or blur commits.

Keyboard

Each endpoint follows Date Field keyboard behavior. Tab moves through start segments, then end segments. Root uses role="group"; each date segment remains a labeled role="spinbutton".