# RangeCalendar

> An inline calendar that selects a start and an end date, with several visible months, hover and focus preview, minimum and maximum spans, blocking disabled days and announced selections.

Canonical: https://salmonui.dev/docs/calendars/range-calendar

`RangeCalendar` shares every prop of [Calendar](https://salmonui.dev/docs/calendars/calendar)
(bounds, disabled days, custom cells, views, weeks, calendar systems,
keyboard) and selects a range instead of single days. It is exported from
`@salmonui/calendars/calendar`.

```tsx
import { getRangeDays, RangeCalendar, type DateRange } from '@salmonui/calendars/calendar';
import '@salmonui/calendars/calendar/styles.css';

const [range, setRange] = useState<DateRange | null>(null);

<RangeCalendar aria-label="Trip dates" visibleMonths={2} minDays={3} maxDays={14} value={range} onValueChange={setRange} />;
```

### Live demo: Range calendar with two months

Live demo: https://salmonui.dev/demos/calendars/range-calendar

RangeCalendar with two visible months, hover and focus preview, minDays and maxDays, a disabled day that blocks the range, and the getRangeDays helper.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { getRangeDays, RangeCalendar, toPlainDate, type DateRange, type PlainDate } from '@salmonui/calendars/calendar';

const TRIP: DateRange = { start: toPlainDate('2026-11-09') as PlainDate, end: toPlainDate('2026-11-13') as PlainDate };

/** A two-month RangeCalendar with a 3 to 14 day span and a blocked holiday. */
export default function RangeCalendarDemo() {
  const [range, setRange] = useState<DateRange | null>(TRIP);
  return (
    <div className="demo-stack">
      <RangeCalendar
        aria-label="Trip dates"
        locale="en-US"
        visibleMonths={2}
        defaultValue={TRIP}
        minDays={3}
        maxDays={14}
        isDateDisabled={(date) => String(date) === '2026-11-26'}
        rangeOverDisabled="block"
        onValueChange={setRange}
      />
      <p className="demo-status" aria-live="polite">
        {range ? (
          <>
            <code>
              {String(range.start)}/{String(range.end)}
            </code>{' '}
            · {getRangeDays(range)} days
          </>
        ) : (
          'Choose a start date, then an end date.'
        )}
      </p>
    </div>
  );
}
```

## Value

`value` / `defaultValue` is a `DateRange<DateInput>` (`{ start, end }`) or
`null`; `onValueChange(range, details)` receives a frozen
`DateRange<PlainDate>` with `start <= end`, and `details.iso` is the ISO
8601 interval `start/end`. The first click (or Enter) chooses the start,
the second the end; the ends may be chosen in either order.
`getRangeDays(range)` returns the inclusive day count.

## Months and preview

- `visibleMonths` (default 1) renders that many months side by side, each
  with its own heading; the previous / next buttons move the window by one
  month and keyboard focus scrolls it as needed.
- While a start is chosen, the range previews to the hovered or focused day:
  those days carry `data-in-range`, and the ends `data-range-start` and
  `data-range-end`.

## Allowed spans

- `minDays` and `maxDays` limit the inclusive length of a range; once a start
  is chosen, the days that would make a shorter or longer range are
  disabled.
- `rangeOverDisabled` decides whether a range may span a day disabled by
  `isDateDisabled`, `min` or `max`: `'block'` (default) disables every day
  past the first disabled day on each side of the start; `'allow'` only
  keeps the ends themselves selectable.

## Announcements

A polite live region announces the selection: the start date when it is
chosen (`localeText.rangeStartSelected`, `{date}`), then the complete range
with its day count (`localeText.selectedRange`, `{start}`, `{end}`,
`{count}`, with plural forms). Month and view changes are announced through
the labelled heading.

```tsx
<RangeCalendar
  locale="de-DE"
  localeText={{
    rangeStartSelected: '{date} als Beginn gewählt',
    selectedRange: { one: '{start} bis {end}, {count} Tag', other: '{start} bis {end}, {count} Tage' },
  }}
/>
```

## API reference

The API reference for
[`@salmonui/calendars/calendar`](https://salmonui.dev/docs/reference/calendars/calendar) lists every
prop, method and type.
