Calendar
Calendar lets the user pick a single date or a date range.
import { Calendar } from '@/components/ui/wideset/calendar/Calendar';
<Calendar mode="single" />Installation
pnpm dlx wideset add calendar
Copies the component and any Wideset components it uses into your project.
Examples
Modes
mode="single" picks one day; mode="range" takes two clicks, start then end, and fills the days between. The calendar opens on the month of the selected date. Inside a form field use Date picker or Date range picker, which wrap this calendar in a popover with an input.
import { Calendar } from '@/components/ui/wideset/calendar/Calendar';
import { useState } from 'react';
/** The shape `mode="range"` selects. */
type DateRange = { from: Date | undefined; to?: Date };
export default function CalendarModes() {
const [day, setDay] = useState<Date | undefined>(new Date(2026, 9, 14));
const [range, setRange] = useState<DateRange | undefined>({
from: new Date(2026, 9, 12),
to: new Date(2026, 9, 16),
});
return (
<div className="gap-ws-11 flex flex-wrap items-start justify-center">
<Calendar mode="single" selected={day} onSelect={setDay} />
<Calendar mode="range" selected={range} onSelect={setRange} />
</div>
);
}Outside days
Off by default, so each month reads as one block. Turn showOutsideDays on when a range often crosses into the next month and the reader needs to see where it continues. Outside days can be picked like any other.
import { Calendar } from '@/components/ui/wideset/calendar/Calendar';
export default function CalendarOutsideDays() {
return (
<div className="gap-ws-11 flex flex-wrap items-start justify-center">
<Calendar mode="single" />
<Calendar mode="single" showOutsideDays />
</div>
);
}States
disabled takes dates, ranges or a matcher such as { before: date } or { dayOfWeek: [0, 6] }; disabled days cannot be picked, and the keyboard skips them. Say why near the calendar when the reason is not obvious, such as "Weekends are closed".
import { Calendar } from '@/components/ui/wideset/calendar/Calendar';
import { useState } from 'react';
export default function CalendarStates() {
const [day, setDay] = useState<Date | undefined>(new Date(2026, 9, 14));
return (
<Calendar
mode="single"
selected={day}
onSelect={setDay}
disabled={[{ dayOfWeek: [0, 6] }, { before: new Date(2026, 9, 7) }]}
footer="Weekends are closed."
/>
);
}API reference
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
monthCaptionAriaLabels | Accessible labels for the month caption navigation buttons and pickers. { prevYear?: string | undefined; prevMonth?: string | undefined; selectMonth?: string | undefined; selectYear?: string | undefined; nextMonth?: string | undefined; nextYear?: string | undefined; } | — |
monthGridLabels | Labels for the month grid picker. { title?: string | undefined; ariaLabel?: string | undefined; months?: string[] | undefined; } | — |
onMonthSelect | Fired when a month is picked from the month popover. Receives the month index (0–11). ((month: number) => void) | — |
onYearSelect | Fired when a year is picked from the year popover. Receives the four-digit year. ((year: number) => void) | — |
yearGridLabels | Labels for the year grid picker. { title?: string | undefined; ariaLabel?: string | undefined; prevYears?: string | undefined; nextYears?: string | undefined; } | — |
yearsPerPage | Number of years shown per page in the year picker popover. Defaults to 16. number | 16 |
Accessibility
- Arrow keys move between days; disabled days are skipped.
- The navigation and picker buttons carry English names by default; override them with
monthCaptionAriaLabels(prevMonth,nextMonth,prevYear,nextYear,selectMonth,selectYear) in other languages.
import { Calendar } from '@/components/ui/wideset/calendar/Calendar';
<Calendar mode="single" />