Menu

Components

Range Calendar

The days of two months in a grid, to pick a range from one day to another, with ready-made ranges beside them.

Introduction

Range Calendar is for picking a period: a stay, a leave, the dates a report covers. The user presses the first day and then the last, and the days between are joined into a band whose ends are marked. It is the calendar to keep on the page, or to put in a panel of your own.

  • It is Calendar in range mode, built on react-aria's RangeCalendar, and takes the same props. Everything works with the keyboard, screen readers announce each day and the range, and the days are written in the user's language.
  • Two months side by side by default, which suits a period that crosses a month. Use one or three if you like.
  • presets lists ready-made ranges beside the days, such as Last 7 days and This month, or ranges of your own. Pressing one sets the range and moves the calendar to it.
  • showSummary says the range and its length under the days, and showClearButton forgets it.
  • The end cannot come before the start, and by default a range cannot run across an unavailable day. Set allowsNonContiguousRanges to let it, with the unavailable days left out of it.

For the same in a field with a button that opens it, use DateRangePicker. It is a Client Component, so a function such as isDateUnavailable must be defined in a client file. The days are drawn in the browser, so a space of the same size holds their place until then.

Installation

centerUI has no CLI or registry yet: components are copied into your project.

# bun
bun add react-aria-components @internationalized/date tailwind-variants tailwind-merge clsx

# pnpm
pnpm add react-aria-components @internationalized/date tailwind-variants tailwind-merge clsx

# npm
npm install react-aria-components @internationalized/date tailwind-variants tailwind-merge clsx

Manual installation

Copy these files into your project and keep the paths, or adjust the imports. Range Calendar is Calendar in range mode, so it needs Calendar and what that needs.

1. Add Calendar

Its component and styles, and the file of the ready-made ranges.

src/components/ui/calendar/calendar.tsxShow code
"use client";

import {
  type CalendarDate,
  type DateValue,
  getLocalTimeZone,
  parseDate,
  today,
} from "@internationalized/date";
import { useContext, useMemo, useSyncExternalStore } from "react";
import {
  Calendar as AriaCalendar,
  RangeCalendar as AriaRangeCalendar,
  CalendarCell,
  CalendarGrid,
  CalendarGridBody,
  CalendarGridHeader,
  CalendarHeaderCell,
  CalendarStateContext,
  Heading,
  RangeCalendarStateContext,
} from "react-aria-components";
import { ChevronLeftIcon, ChevronRightIcon } from "@/components/icons";
import { Button } from "@/components/ui/button/button";
import { cn } from "@/lib/cn";
import { calendarStyles } from "@/types/calendar-styles";
import {
  type DateRangePresetInput,
  resolveDateRangePreset,
} from "@/types/date-range-presets";

/** A date as text, `"2026-03-15"`. */
export type CalendarDateText = string;

/** A range of dates: from the first to the last, as text. */
export interface CalendarRange {
  start: CalendarDateText;
  end: CalendarDateText;
}

interface BaseProps {
  /** Names the calendar for screen readers, such as "Departure date". */
  "aria-label"?: string;
  /** The earliest date that can be picked, `"2026-03-01"`. Earlier days are dimmed and cannot be reached. */
  minValue?: CalendarDateText;
  /** The latest date that can be picked. */
  maxValue?: CalendarDateText;
  /** Dates that cannot be picked, such as days that are booked. They are struck through, but can still be moved onto. */
  unavailableDates?: CalendarDateText[];
  /** Days of the week that cannot be picked, from 0 (Sunday) to 6 (Saturday). `[0, 6]` is the weekend. */
  disabledWeekdays?: number[];
  /** Decides for each date if it cannot be picked, for rules the two props above cannot say. Called with `"2026-03-15"`. */
  isDateUnavailable?: (date: CalendarDateText) => boolean;
  /** The month to show first, as a date of that month, when nothing is picked. Defaults to today. */
  defaultFocusedValue?: CalendarDateText;
  /** The first day of the week. Defaults to the one of the user's language. */
  firstDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
  /** How many months are shown side by side, from 1 to 3. Defaults to 1. */
  visibleMonths?: 1 | 2 | 3;
  /** What the arrows move by: every month shown (`visible`), or one month at a time (`single`). Defaults to `visible`. */
  pageBehavior?: "visible" | "single";
  /** The days of the neighbouring months that fill the first and last week. Defaults to `false`. */
  showOutsideDays?: boolean;
  /** A "Today" button under the days, which moves to the month of today. Defaults to `false`. */
  showTodayButton?: boolean;
  /** The text of that button. Defaults to "Today". */
  todayLabel?: string;
  /** Nothing can be picked or moved. */
  isDisabled?: boolean;
  /** Days can be looked at and moved between, but not picked. */
  isReadOnly?: boolean;
  /** Focus a day when it is first shown. */
  autoFocus?: boolean;
  /** How big the days are. Defaults to `md`. */
  size?: "sm" | "md" | "lg";
  /** A card with a border and padding, or nothing around the days, to sit in a popover or a panel. Defaults to `card`. */
  variant?: "card" | "plain";
  className?: string;
}

interface SingleProps {
  /** One day (the default), several days, or a range from one day to another. */
  selectionMode?: "single";
  /** The picked date as text, `"2026-03-15"`, or `null` for none. For a controlled calendar. */
  value?: CalendarDateText | null;
  /** The date to start with, for an uncontrolled calendar. */
  defaultValue?: CalendarDateText | null;
  onChange?: (value: CalendarDateText | null) => void;
}

interface MultipleProps {
  selectionMode: "multiple";
  /** The picked dates as text, in any order. For a controlled calendar. */
  value?: CalendarDateText[];
  defaultValue?: CalendarDateText[];
  onChange?: (value: CalendarDateText[]) => void;
}

interface RangeProps {
  selectionMode: "range";
  /** Ranges offered in a list beside the days, to pick in one press: the names of ready-made ones, or ranges of your own. Ready-made ranges are worked out from today. */
  presets?: DateRangePresetInput[];
  /** A line under the days that says the range and how many days it has. Defaults to `false`. */
  showSummary?: boolean;
  /** A "Clear" button under the days. Defaults to `false`. */
  showClearButton?: boolean;
  /** The text of that button. Defaults to "Clear". */
  clearLabel?: string;
  /** Let the range run across days that are unavailable, which stay out of it. Defaults to `false`. */
  allowsNonContiguousRanges?: boolean;
  /** The picked range, `{ start: "2026-03-10", end: "2026-03-14" }`, or `null` for none. For a controlled calendar. */
  value?: CalendarRange | null;
  defaultValue?: CalendarRange | null;
  onChange?: (value: CalendarRange | null) => void;
}

export type CalendarProps = BaseProps &
  (SingleProps | MultipleProps | RangeProps);

function toDate(text: string | null | undefined): CalendarDate | null {
  if (!text) return null;
  try {
    return parseDate(text);
  } catch {
    return null;
  }
}

const toDates = (list: string[] | undefined) =>
  (list ?? []).map(toDate).filter((d): d is CalendarDate => d !== null);

function toRange(range: CalendarRange | null | undefined) {
  const start = toDate(range?.start);
  const end = toDate(range?.end);
  return start && end ? { start, end } : null;
}

// Jumps to the month of today. The calendar it is in provides its state.
function TodayButton({ children }: { children: string }) {
  const single = useContext(CalendarStateContext);
  const range = useContext(RangeCalendarStateContext);
  const state = single ?? range;

  return (
    <Button
      // Not one of the arrows: a button of the calendar's own must say so.
      slot={null}
      variant="ghost"
      size="sm"
      onPress={() => state?.setFocusedDate(today(getLocalTimeZone()))}
    >
      {children}
    </Button>
  );
}

const summaryFormat = new Intl.DateTimeFormat(undefined, {
  dateStyle: "medium",
});

// What the range is and how long: "Mar 10, 2026 to Mar 14, 2026 · 5 days".
function RangeSummary({ className }: { className: string }) {
  const state = useContext(RangeCalendarStateContext);
  const value = state?.value;
  if (!value?.start || !value.end) {
    return <span className={className}>Pick the first and the last day</span>;
  }
  const days = value.end.compare(value.start) + 1;
  const zone = getLocalTimeZone();
  return (
    <span className={className}>
      {summaryFormat.format(value.start.toDate(zone))} to{" "}
      {summaryFormat.format(value.end.toDate(zone))}
      <span className="text-muted-fg">
        {" "}
        · {days} {days === 1 ? "day" : "days"}
      </span>
    </span>
  );
}

// Forgets the picked range.
function ClearButton({ children }: { children: string }) {
  const state = useContext(RangeCalendarStateContext);

  return (
    <Button
      // Not one of the arrows: a button of the calendar's own must say so.
      slot={null}
      variant="ghost"
      size="sm"
      isDisabled={!state?.value}
      onPress={() => state?.setValue(null)}
    >
      {children}
    </Button>
  );
}

/**
 * A list of ready-made ranges to pick in one press, for a range calendar or a
 * range picker. It is given the range now picked, to mark the one that matches,
 * and what to do when one is pressed.
 */
export function RangePresetList({
  presets,
  value,
  min,
  max,
  onPick,
  className,
  buttonClassName,
}: {
  presets: DateRangePresetInput[];
  value: { start: DateValue; end: DateValue } | null;
  min?: DateValue;
  max?: DateValue;
  onPick: (range: { start: CalendarDate; end: CalendarDate }) => void;
  className: string;
  buttonClassName: string;
}) {
  const now = today(getLocalTimeZone());

  return (
    // biome-ignore lint/a11y/useSemanticElements: a fieldset would bring a border and a legend of its own
    <div role="group" aria-label="Quick ranges" className={className}>
      {presets.map((preset) => {
        const { label, start, end } = resolveDateRangePreset(preset, now);
        const isOutside =
          (min !== undefined && start.compare(min) < 0) ||
          (max !== undefined && end.compare(max) > 0);
        const isActive =
          value !== null &&
          value.start.compare(start) === 0 &&
          value.end.compare(end) === 0;

        return (
          <Button
            key={label}
            // Not one of the arrows, nor the button that opens a picker.
            slot={null}
            variant={isActive ? "secondary" : "ghost"}
            size="sm"
            className={buttonClassName}
            aria-pressed={isActive}
            isDisabled={isOutside}
            onPress={() => onPick({ start, end })}
          >
            {label}
          </Button>
        );
      })}
    </div>
  );
}

// The presets of a range calendar: they set the calendar it is in.
function CalendarPresets({
  presets,
  min,
  max,
  className,
  buttonClassName,
}: {
  presets: DateRangePresetInput[];
  min?: DateValue;
  max?: DateValue;
  className: string;
  buttonClassName: string;
}) {
  const state = useContext(RangeCalendarStateContext);
  const value = state?.value;

  return (
    <RangePresetList
      presets={presets}
      value={
        value?.start && value.end
          ? { start: value.start, end: value.end }
          : null
      }
      min={min}
      max={max}
      className={className}
      buttonClassName={buttonClassName}
      onPick={(range) => {
        state?.setValue(range);
        state?.setFocusedDate(range.start);
      }}
    />
  );
}

type CalendarStyles = ReturnType<typeof calendarStyles>;

/**
 * The inside of a calendar: the header with its arrows, the grids of days, and
 * the Today button. `Calendar` and the panel of `DatePicker` both draw it, each
 * inside the react-aria calendar it belongs to.
 */
export function CalendarBody({
  styles,
  visibleMonths,
  showTodayButton,
  todayLabel,
  showSummary = false,
  showClearButton = false,
  clearLabel = "Clear",
}: {
  styles: CalendarStyles;
  visibleMonths: number;
  showTodayButton: boolean;
  todayLabel: string;
  showSummary?: boolean;
  showClearButton?: boolean;
  clearLabel?: string;
}) {
  return (
    <>
      <header className={styles.header()}>
        <Button slot="previous" variant="ghost" isIcon size="sm">
          <ChevronLeftIcon />
        </Button>
        <Heading className={styles.heading()} />
        <Button slot="next" variant="ghost" isIcon size="sm">
          <ChevronRightIcon />
        </Button>
      </header>
      <div className={styles.months()}>
        {Array.from({ length: visibleMonths }, (_, i) => (
          <CalendarGrid
            // biome-ignore lint/suspicious/noArrayIndexKey: the months are the positions
            key={i}
            offset={{ months: i }}
            className={styles.grid()}
          >
            <CalendarGridHeader>
              {(day) => (
                <CalendarHeaderCell className={styles.headerCell()}>
                  {day}
                </CalendarHeaderCell>
              )}
            </CalendarGridHeader>
            <CalendarGridBody>
              {(date) => <CalendarCell date={date} className={styles.cell()} />}
            </CalendarGridBody>
          </CalendarGrid>
        ))}
      </div>
      {showTodayButton || showSummary || showClearButton ? (
        <div className={styles.footer()}>
          {showSummary ? <RangeSummary className={styles.summary()} /> : null}
          {showClearButton ? <ClearButton>{clearLabel}</ClearButton> : null}
          {showTodayButton ? <TodayButton>{todayLabel}</TodayButton> : null}
        </div>
      ) : null}
    </>
  );
}

/**
 * Turns the ways to say that a date is not allowed into one function for
 * react-aria: a list of dates, days of the week, and a rule of your own.
 */
export function createUnavailable(
  unavailableDates: string[] | undefined,
  disabledWeekdays: number[] | undefined,
  isDateUnavailable: ((date: string) => boolean) | undefined,
) {
  const blocked = new Set(unavailableDates);
  return (date: DateValue) => {
    const text = date.toString();
    return (
      blocked.has(text) ||
      Boolean(disabledWeekdays?.includes(date.toDate("UTC").getUTCDay())) ||
      Boolean(isDateUnavailable?.(text))
    );
  };
}

/**
 * A calendar to pick a date, several dates, or a range of dates from: the days
 * of a month in a grid, with arrows to go to the next or the previous. Built on
 * react-aria's Calendar, so everything works with the keyboard (arrow keys move
 * by a day or a week, Page Up and Down by a month, Home and End to the start and
 * end of the week), screen readers announce each day, and the days and months
 * are written in the user's language and calendar.
 *
 * Dates are plain text, `"2026-03-15"`, which is what a form and a database
 * want. A date has no time and no time zone.
 *
 * @example
 * <Calendar aria-label="Date of birth" value={date} onChange={setDate} />
 * <Calendar selectionMode="range" aria-label="Stay" onChange={setStay} />
 */
export function Calendar(props: CalendarProps) {
  const {
    minValue,
    maxValue,
    unavailableDates,
    disabledWeekdays,
    isDateUnavailable,
    defaultFocusedValue,
    firstDayOfWeek,
    visibleMonths = 1,
    pageBehavior,
    showOutsideDays = false,
    showTodayButton = false,
    todayLabel = "Today",
    size = "md",
    variant,
    className,
    ...rest
  } = props;
  const isRange = props.selectionMode === "range";
  const styles = calendarStyles({
    variant,
    size,
    mode: isRange ? "range" : "single",
    showOutsideDays,
  });
  // False on the server and while the page hydrates, true after. The days and
  // their names are written for the user's language and time zone, which the
  // server does not know, so they are drawn in the browser only.
  const isClient = useSyncExternalStore(
    () => () => {},
    () => true,
    () => false,
  );

  const min = useMemo(() => toDate(minValue) ?? undefined, [minValue]);
  const max = useMemo(() => toDate(maxValue) ?? undefined, [maxValue]);
  const focus = useMemo(
    () => toDate(defaultFocusedValue) ?? undefined,
    [defaultFocusedValue],
  );

  const unavailable = createUnavailable(
    unavailableDates,
    disabledWeekdays,
    isDateUnavailable,
  );

  const shared = {
    "aria-label": rest["aria-label"],
    minValue: min,
    maxValue: max,
    isDateUnavailable: unavailable,
    defaultFocusedValue: focus,
    firstDayOfWeek,
    visibleDuration: { months: visibleMonths },
    pageBehavior,
    isDisabled: rest.isDisabled,
    isReadOnly: rest.isReadOnly,
    autoFocus: rest.autoFocus,
    className: cn(styles.root(), className),
  };

  const body = (
    <CalendarBody
      styles={styles}
      visibleMonths={visibleMonths}
      showTodayButton={showTodayButton}
      todayLabel={todayLabel}
    />
  );

  if (!isClient) {
    return (
      <div
        aria-hidden="true"
        className={cn(styles.root(), styles.placeholder(), className)}
      />
    );
  }

  if (props.selectionMode === "range") {
    return (
      <AriaRangeCalendar
        {...shared}
        {...(props.value !== undefined
          ? { value: toRange(props.value) }
          : { defaultValue: toRange(props.defaultValue) })}
        onChange={(next) =>
          props.onChange?.(
            next
              ? { start: next.start.toString(), end: next.end.toString() }
              : null,
          )
        }
        allowsNonContiguousRanges={props.allowsNonContiguousRanges}
      >
        <div className={styles.panel()}>
          {props.presets?.length ? (
            <CalendarPresets
              presets={props.presets}
              min={min}
              max={max}
              className={styles.presets()}
              buttonClassName={styles.preset()}
            />
          ) : null}
          <div className={styles.main()}>
            <CalendarBody
              styles={styles}
              visibleMonths={visibleMonths}
              showTodayButton={showTodayButton}
              todayLabel={todayLabel}
              showSummary={props.showSummary}
              showClearButton={props.showClearButton}
              clearLabel={props.clearLabel}
            />
          </div>
        </div>
      </AriaRangeCalendar>
    );
  }

  if (props.selectionMode === "multiple") {
    return (
      <AriaCalendar
        {...shared}
        selectionMode="multiple"
        {...(props.value !== undefined
          ? { value: toDates(props.value) }
          : { defaultValue: toDates(props.defaultValue) })}
        onChange={(next) => props.onChange?.(next.map((d) => d.toString()))}
      >
        {body}
      </AriaCalendar>
    );
  }

  return (
    <AriaCalendar
      {...shared}
      {...(props.value !== undefined
        ? { value: toDate(props.value) }
        : { defaultValue: toDate(props.defaultValue) })}
      onChange={(next) => props.onChange?.(next ? next.toString() : null)}
    >
      {body}
    </AriaCalendar>
  );
}
src/types/date-range-presets.tsShow code
import {
  type CalendarDate,
  endOfMonth,
  endOfYear,
  parseDate,
  startOfMonth,
  startOfYear,
} from "@internationalized/date";

// The ready-made ranges of a range calendar or a range picker, each worked out
// from today, and the shape of a range of your own. It knows nothing about React.

/** The ready-made ranges a range picker can offer, worked out from today. */
export type DateRangePresetKey =
  | "today"
  | "yesterday"
  | "last7"
  | "last14"
  | "last30"
  | "last90"
  | "thisMonth"
  | "lastMonth"
  | "thisYear";

/** A range of your own to offer, such as a fiscal quarter. */
export interface DateRangePreset {
  label: string;
  value: { start: string; end: string };
}

/** What `presets` is made of: the name of a ready-made range, or a range of your own. */
export type DateRangePresetInput = DateRangePresetKey | DateRangePreset;

export const presetDefinitions: Record<
  DateRangePresetKey,
  { label: string; range: (now: CalendarDate) => [CalendarDate, CalendarDate] }
> = {
  today: { label: "Today", range: (now) => [now, now] },
  yesterday: {
    label: "Yesterday",
    range: (now) => [now.subtract({ days: 1 }), now.subtract({ days: 1 })],
  },
  last7: {
    label: "Last 7 days",
    range: (now) => [now.subtract({ days: 6 }), now],
  },
  last14: {
    label: "Last 14 days",
    range: (now) => [now.subtract({ days: 13 }), now],
  },
  last30: {
    label: "Last 30 days",
    range: (now) => [now.subtract({ days: 29 }), now],
  },
  last90: {
    label: "Last 90 days",
    range: (now) => [now.subtract({ days: 89 }), now],
  },
  thisMonth: {
    label: "This month",
    range: (now) => [startOfMonth(now), endOfMonth(now)],
  },
  lastMonth: {
    label: "Last month",
    range: (now) => {
      const before = startOfMonth(now).subtract({ days: 1 });
      return [startOfMonth(before), endOfMonth(before)];
    },
  },
  thisYear: {
    label: "This year",
    range: (now) => [startOfYear(now), endOfYear(now)],
  },
};

/** A set of ranges that covers most needs. */
export const defaultDateRangePresets: DateRangePresetKey[] = [
  "today",
  "yesterday",
  "last7",
  "last30",
  "thisMonth",
  "lastMonth",
];

/** A preset as a label and two dates, whichever way it was given. */
export function resolveDateRangePreset(
  preset: DateRangePresetInput,
  now: CalendarDate,
): { label: string; start: CalendarDate; end: CalendarDate } {
  if (typeof preset === "string") {
    const [start, end] = presetDefinitions[preset].range(now);
    return { label: presetDefinitions[preset].label, start, end };
  }
  return {
    label: preset.label,
    start: parseDate(preset.value.start),
    end: parseDate(preset.value.end),
  };
}

2. Add the Range Calendar file

src/components/ui/range-calendar/range-calendar.tsxShow code
"use client";

import {
  Calendar,
  type CalendarProps,
} from "@/components/ui/calendar/calendar";

/** The props of `Calendar` in range mode, less `selectionMode`, which is always `range`. */
export type RangeCalendarProps = Omit<
  Extract<CalendarProps, { selectionMode: "range" }>,
  "selectionMode"
>;

/**
 * A calendar to pick a range of dates from: press the first day and then the
 * last, and the days between are joined into a band whose ends are marked. Use
 * it for a stay, a period to report on, or a leave. It shows two months side by
 * side, and can list ready-made ranges such as "Last 7 days" beside the days,
 * and say the range and its length under them.
 *
 * It is `Calendar` in range mode, built on react-aria's RangeCalendar, so the
 * keyboard, the screen reader announcements and the language of the days all
 * come from there. The value is `{ start, end }`, two dates as text, and `null`
 * until a range is picked. The end may not come before the start. For the same
 * in a field with a button, use `DateRangePicker`.
 *
 * @example
 * <RangeCalendar
 *   aria-label="Length of stay"
 *   presets={["last7", "last30"]}
 *   showSummary
 *   onChange={setStay}
 * />
 */
export function RangeCalendar({
  visibleMonths = 2,
  ...props
}: RangeCalendarProps) {
  return (
    <Calendar selectionMode="range" visibleMonths={visibleMonths} {...props} />
  );
}

3. Use it

import { RangeCalendar } from "@/components/ui/range-calendar/range-calendar";

Anatomy

A list of ready-made ranges, and the days of two months with a footer.

<RangeCalendar
  aria-label="Length of stay"
  presets={["last7", "last30"]}
  showSummary
  showClearButton
  defaultValue={{ start: "2026-03-10", end: "2026-03-14" }}
/>
PartRendered asNotes
Presetsbutton groupReady-made ranges in a column beside the days, or in a row above them on a narrow screen. The one that matches the range is marked.
HeaderheaderThe arrows to the previous and the next month, and the months shown between them.
Daystd, divTwo months by default. The days of the range are joined into a band, and its first and last day are marked.
FooterdivThe summary of the range, and the Clear and Today buttons.

Value

A range is two dates as text, each with the year first.

// A range: two dates as text, year first
{ start: "2026-03-10", end: "2026-03-14" }

null   // no range picked

Keyboard

The days are a grid with one place in the tab order, and the keys move inside it.

KeyAction
Arrow keysMove by a day or by a week. With the start set, the band follows the focus.
Page Up, Page DownMove by a month. With Shift, by a year.
Home, EndMove to the start or the end of the week.
Enter, SpaceThe first press sets the start of the range, and the second sets its end.
EscapeForget a start that was pressed, and begin again.

Examples

Usage

Press the first day and then the last.

Default value

Start with a range. The calendar opens on the month of its start.

Controlled

Keep the range in your own state with value and onChange, which gets two dates as text, or null when it is cleared.

March 10, 2026 to March 14, 2026: 5 days

Ready-made ranges

presets lists the names of ready-made ranges. They are worked out from today, and the one that matches the range is marked. Pressing one sets the range and moves to its month.

NameRange
todayToday
yesterdayYesterday
last7Last 7 days, ending today
last14Last 14 days
last30Last 30 days
last90Last 90 days
thisMonthThis month, from the 1st to its last day
lastMonthThe whole of the month before
thisYearThis year, from January 1 to December 31

Ranges of your own

Mix in ranges of your own with a label and a fixed range, such as quarters of a fiscal year.

Summary and clear

showSummary says the range and how many days it has, or asks for the first and the last day. showClearButton forgets the range, and showTodayButton moves to the month of today.

How many months

Two months by default. Use one for a narrow place, or three for a long period.

Across unavailable days

A range cannot run across an unavailable day, so it has to stop before it. allowsNonContiguousRanges lets it run across, and the unavailable days stay out of it.

Earliest and latest

Days outside the limits are dimmed and cannot be reached, and a ready-made range that goes outside them is disabled.

Unavailable days

unavailableDates lists days that cannot be picked, and disabledWeekdays days of the week, from 0 for Sunday. They are struck through.

Your own rule

isDateUnavailable is called for each day, with its date as text. Here nothing is delivered on the 13th, so no range can include it.

First day of the week

It follows the user's language, and firstDayOfWeek sets it. showOutsideDays fills the first and the last week with days of the months around.

Sizes

Variants

A card with a border and padding, or nothing around the days, to sit inside a panel that has its own.

Disabled and read only

A disabled calendar cannot be used at all. A read only one can be moved between months and days but not picked from, to show a period that is already set.

Component API

Range Calendar takes the props below, which are those of Calendar in range mode.

PropTypeDefault
value{ start: string, end: string } | null-
defaultValue{ start: string, end: string } | null-
onChange(value: { start, end } | null) => void-
aria-labelstring-
presets(DateRangePresetKey | { label, value })[]-
showSummarybooleanfalse
showClearButtonbooleanfalse
clearLabelstring"Clear"
allowsNonContiguousRangesbooleanfalse
minValuestring-
maxValuestring-
unavailableDatesstring[]-
disabledWeekdaysnumber[]-
isDateUnavailable(date: string) => boolean-
defaultFocusedValuestringthe start of the range, or today
firstDayOfWeek"sun" | "mon" | ... | "sat"the user's language
visibleMonths1 | 2 | 32
pageBehavior"visible" | "single""visible"
showOutsideDaysbooleanfalse
showTodayButtonbooleanfalse
todayLabelstring"Today"
isDisabledbooleanfalse
isReadOnlybooleanfalse
autoFocusbooleanfalse
size"sm" | "md" | "lg""md"
variant"card" | "plain""card"
classNamestring-