Calendar
A month grid with single, multiple and range selection, locales and date constraints.
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Pick a date
"use client";
import { useState } from "react";
import { Calendar, Text, VStack } from "astralis-ui";
export function CalendarDemo() {
const [date, setDate] = useState<Date | null>(null);
return (
<VStack gap="3">
<Calendar
selectionMode="single"
value={date}
onValueChange={(next) => setDate(next instanceof Date ? next : null)}
>
<Calendar.Header>
<Calendar.PrevTrigger />
<Calendar.ViewTrigger />
<Calendar.NextTrigger />
</Calendar.Header>
<Calendar.Weekdays />
<Calendar.Grid />
</Calendar>
<Text size="xs" color="muted">
{date ? `Selected: ${date.toDateString()}` : "Pick a date"}
</Text>
</VStack>
);
}Import#
import { Calendar } from "astralis-ui";
// Calendar.Header, .PrevTrigger, .ViewTrigger, .NextTrigger,
// .Weekdays, .Grid, .CellRange selection#
selectionMode="range" returns { start, end }; firstDayOfWeek={1} starts
weeks on Monday, and weekday names follow the locale.
Mon
Tue
Wed
Thu
Fri
Sat
Sun
"use client";
import { Calendar } from "astralis-ui";
export function CalendarRange() {
return (
/* Range mode: click a start, then an end; days between highlight. */
<Calendar selectionMode="range" firstDayOfWeek={1} size="sm">
<Calendar.Header>
<Calendar.PrevTrigger />
<Calendar.ViewTrigger />
<Calendar.NextTrigger />
</Calendar.Header>
<Calendar.Weekdays />
<Calendar.Grid />
</Calendar>
);
}Props#
| Prop | Type | Default | Description |
|---|---|---|---|
selectionMode | "single" | "multiple" | "range" | "single" | What a click selects. |
value / defaultValue / onValueChange | Date | Date[] | { start, end } | null | — | Controlled / uncontrolled API, shaped by the mode. |
defaultMonth | Date | today | Initially visible month. |
locale | string | "en-US" | Intl locale for month/weekday names. |
firstDayOfWeek | 0 – 6 | 0 | 0 = Sunday, 1 = Monday… |
minDate / maxDate / isDateUnavailable | Date / Date / (date) => boolean | — | Selection constraints. |
showOutsideDays | boolean | true | Render the adjacent months' spill-over days. |
size | "sm" | "md" | "lg" | "md" | Cell size. |
Keyboard#
With focus on the day grid:
| Key | Action |
|---|---|
← / → | Previous / next day |
↑ / ↓ | Previous / next week |
Home / End | Start / end of the week |
PageUp / PageDown | Previous / next month (same day) |
Enter / Space | Select the focused day |
Moving past a month boundary flips the visible month and keeps focus on the day — no extra keystrokes needed.
Accessibility#
Every day cell is a real button with a full-date aria-label; the previous
and next triggers are labeled, and unavailable dates use the native
disabled attribute.