Skip to content

Date Range Picker

Enter a date range by typing or selecting from a calendar.

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

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 DateRangePicker.vue and index.ts into app/components/ui/date-range-picker/. Also copy the required components: Calendar, Date Field, Date Range Field.

API

Variants and defaults

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

Models

ModelTypeDefaultDescription
v-modelCalendarDateRange{}Shared typed and calendar-selected range.
v-model:openbooleanfalsePopup open state.
v-model:placeholderCalendarDateValueselected endpoint or todayFirst visible calendar month.

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

Props

Date Range Picker accepts Date Range Field props id, name, startName, endName, locale, dir, minValue, maxValue, isDateUnavailable, allowNonContiguousRanges, maximumDays, fixedDate, required, disabled, readOnly, invalid, selectOnFocus, autoAdvance, endpoint labels, and ARIA relationships.

PropTypeDefaultDescription
rangeColor"secondary" | "accent""secondary"Preview and committed middle fill; endpoints use primary.
isDateDisabled(date) => boolean-Calendar-only disabled-date rule.
calendarLabelstring"Choose date range"Trigger and popup accessible label.
closeLabelstring-Renders an explicit close button with this label.
closeOnSelectbooleantrueCloses after both endpoints are selected.
weekStartsOn"sun" | "mon" | ...locale defaultExplicit first weekday.
weekdayFormat"narrow" | "short" | "long""narrow"Visible weekday format.
fixedWeeksbooleanfalseRenders six weeks per month for stable popup height.
numberOfMonthsnumber1Adjacent month grids.
pagedNavigationbooleanfalseMoves by numberOfMonths.
disableDaysOutsideCurrentViewbooleanfalseBlocks selecting outside days.
nextPage(placeholder) => CalendarDateValueadd month(s)Custom next page calculation.
prevPage(placeholder) => CalendarDateValuesubtract month(s)Custom previous page calculation.
side"top" | "right" | "bottom" | "left""bottom"Preferred popup side with collision flipping.
align"start" | "center" | "end""start"Popup alignment.
sideOffsetnumber6Trigger-to-popup gap in pixels.
teleportstring | false"body"Teleport target; false keeps popup beside root.
uiDateRangePickerUi-Classes and nested field/calendar UI maps.

Slots

SlotPropsDescription
start-literalvalueStart endpoint locale separator.
separator-Endpoint separator.
end-literalvalueEnd endpoint locale separator.
triggerisOpen, open, close, toggleCalendar trigger content. Actions are native event-handler safe.
calendarvalue, closeReplaces built-in Calendar.
previousdisabledBuilt-in Calendar previous control content.
headinglabel, monthsBuilt-in Calendar heading.
nextdisabledBuilt-in Calendar next control content.
weekdaydate, labelBuilt-in weekday content.
dayComplete CalendarDay stateBuilt-in day button content.
footervalue, placeholderOptional built-in Calendar footer.
closecloseExplicit close-button content.

Events

EventPayloadDescription
update:modelValueCalendarDateRangeFires after accepted typed or calendar changes.
value-change(range, details)Fires before value changes. details.cancel() prevents update.
value-commit(range, details)Fires after accepted field or calendar commits.
update:openbooleanFires after accepted popup state changes.
open-change(open, details)Fires before popup changes. Cancelable.
update:placeholderCalendarDateValueFires after accepted visible-month changes.
placeholder-change(date, details)Fires before visible-month changes. Cancelable.

Open reasons include trigger, select, escape, outside-click, and programmatic. Value reasons match Date Range Field plus calendar.