Calendar
calendarA month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
"use client";
import { useState } from "react";
import { Calendar } from "@/components/forme/calendar/calendar";
import type { DateRange } from "@/components/forme/calendar/calendar";
const fmt = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
export function CalendarDemo() {
const [today] = useState(() => new Date());
const [date, setDate] = useState<Date>(today);
const [range, setRange] = useState<DateRange>({
from: new Date(today.getFullYear(), today.getMonth(), today.getDate() + 3),
to: new Date(today.getFullYear(), today.getMonth(), today.getDate() + 8),
});
return (
<div className="flex flex-wrap gap-6">
<div className="rounded-xl border border-border bg-card p-4 shadow-xs">
<Calendar selected={date} onSelect={setDate} weekStartsOn={1} />
<p className="mt-3 border-t border-border pt-3 text-caption-1-regular text-muted-foreground">
Due {fmt.format(date)}
</p>
</div>
<div className="rounded-xl border border-border bg-card p-4 shadow-xs">
<Calendar
mode="range"
selected={range}
onSelect={setRange}
min={today}
isDisabled={(day) => day.getDay() === 0 || day.getDay() === 6}
/>
<p className="mt-3 border-t border-border pt-3 text-caption-1-regular text-muted-foreground">
{range.to
? `${fmt.format(range.from)} – ${fmt.format(range.to)} · weekdays only`
: `From ${fmt.format(range.from)}, pick an end date`}
</p>
</div>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
When to use
Reach for it
- Picking a date or a span by browsing: a due date, a stay, a report period.
DateRangePickerwraps it in a popover with a trigger.
Use something else
- Dates people know by heart, like a birthday: typing is faster than paging back decades.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
Calendar
A month grid for picking a date or a range.
| Prop | Type | Default | Description |
|---|---|---|---|
mode | "single" | — | |
selected | Date | DateRange | — | |
onSelect | (date: Date) => void | — | |
defaultMonth | Date | — | The month shown first. Defaults to the selection, or today. |
weekStartsOn | 0 | 1 | 0 | 0 is Sunday, 1 is Monday. |
min | Date | — | |
max | Date | — | |
isDisabled | (date: Date) => boolean | — | Return true for any date that cannot be picked: weekends, booked days. |
locale | string | "en-US" | |
className | string | — |
Accessibility
- One day is in the tab order; arrows, Home, End and Page Up/Down follow the WAI-ARIA date grid, and disabled days stay focusable and are announced as unavailable.
- Picking a start, an end or a refused range is announced, and Escape in the month or year picker returns to the days without closing a surrounding popover.
Motion
- Months slide 8px in the direction of travel over 150ms and leave faster on the exit curve; reduced motion keeps only the fade.
- The range band follows the pointer on the frame: a fading band trails a moving hand.
Responsive behaviour
- Fills its container up to 18rem; the month and year pickers take exactly the day grid's height.
Related
Date Range Picker
A button that opens a calendar for a date range: the range said in words on the trigger, a day count, Clear and Done, and optional presets. Ranges can refuse disabled days inside them, for bookings.
inputsColor picker
A full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
inputsColor selector
A row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
inputs