Skip to content

Date Range Input

@astryxdesign/core v0.7.1 · DateRangeInput

Usage ​

DateRangeInput selects a start date and an end date. The value is { start, end } with ISO dates, or null.

vue
<script setup lang="ts">
import type { DateRange } from '@astryx-vue/core/DateRangeInput'
import { DateRangeInput } from '@astryx-vue/core/DateRangeInput'
import { shallowRef } from 'vue'

const range = shallowRef<DateRange | null>(null)
</script>

<template>
  <DateRangeInput v-model="range" label="Date range" />
</template>

The popover shows two months under one header. The first click sets the start. The second click commits the range when the span is allowed. Clicking the start again commits a single day when the shortest span is one day, and cancels the selection otherwise. The closed field omits the year when both ends are in the current year. Presets stay beside the calendars. When the two months no longer fit side by side, they wrap onto separate rows. A constraint can still turn individual days off. While a change is saving, the field cannot be edited.

Anatomy

ElementDescription
LabelText above the trigger describing what date range is expected.
Field surfaceBordered control containing the calendar toggle, range trigger, and end affordances.
Trigger buttonA button showing the formatted range or placeholder. Clicking opens the popover.
Calendar iconA trailing icon that also opens the popover.
Calendar popoverA dual-month calendar grid with range selection and hover preview.
Preset sidebarA list of preset range options beside the calendar.
Preset buttonA quick-select action for one preset range, reflecting current and disabled states.
Clear buttonA × button that resets the range to null.
Status messageAn error, warning, or success message below the trigger.

Best practices ​

GuidelinePractice
DoOffer presets for the ranges people pick most often.
DoSet minRangeSpan and maxRangeSpan when a one-day or a very long range is invalid. Counts include both ends.
Don'tUse it for one date. DateInput is the control for that.

Examples ​

Validation

Selected dates are no longer available
High demand — limited availability
Dates confirmed and available

Error, warning, and success on a filled range.

With presets

No range selected
Use a preset or pick a custom range

Presets for the last 7, 14, 30, and 90 days, or a custom range.