DateRange
Two dates and the days between them, picked on two months side by side or one, with the span drawn before it is committed.
Import
import { DateRange } from '@vitral/vue';Two months
The default. Pick a start, then an end; the band between them follows the pointer before you commit. Each calendar stops at its own month — the days either side are left blank rather than repeating the month next door.
One month
The same range in a single calendar, for a form with no room for two. With no neighbour to repeat, the days either side of the month come back.
With the spans people ask for by name
The footer is a slot: presets, a count of nights, whatever the form needs.
Inline
Without the text box or the popup.
Showing the neighbouring days anyway
`show-other-months` overrides what the number of calendars decided. Two months with their edges drawn: February’s last days appear again as March’s first, and a range spanning the boundary is painted twice.
The shape of it
API
Read from packages/vue/src/components/DateRange/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| months | number | How many months to show side by side. Two is the default and the reason this component exists: a span that crosses a month boundary is chosen in one gesture rather than by paging. One shows the same range in a single calendar. |
| showOtherMonths | boolean | Whether the days either side of each month are drawn. Left unset, they are on a single calendar and off on several: with two months side by side the last days of one are the first days of the next, so the same date appears twice, a range paints across both copies, and the boundary between the calendars stops meaning anything. The cells stay — the grid keeps its six rows and its height — they are simply left empty. |
| dateFormat | string | A `formatDate` pattern; defaults to the locale's `dateFormat`. |
| separator | string | Between the two dates in the text box. |
| minDate | Date | null | — |
| maxDate | Date | null | — |
| disabledDates | Date[] | — |
| disabledDays | number[] | Weekdays that cannot be chosen, 0 = Sunday. |
| showClearButton | boolean | A footer button that empties the range. |
| firstDayOfWeek | number | 0 = Sunday; defaults to the locale's `firstDayOfWeek`. |
| placeholder | string | — |
| inline | boolean | Show the calendars in place, without a text box or popup. |
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
| fluid | boolean | — |
| placement | OverlayPlacement | — |
| appendTo | string | `'body'` (the default), `'self'` to render in place, or a selector. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| rangeSelect | range: DateRangeValue | Both ends are down. Fires once a range is whole, not on the first press. |
| clear | — | — |
| show | — | — |
| hide | — | — |
| monthChange | event: { month: number; year: number } | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| date | (props: { date: Date; day: number; today: boolean; inRange: boolean; end: 'start' | 'end' | null; disabled: boolean; otherMonth: boolean }) | A day's content. |
| footer | (props: { range: DateRangeValue; nights: number; clear: () => void }) | Under the calendars: presets, a count of nights, a pair of buttons. |