Components / Inputs
Calendar
Month grid (MUI X's DateCalendar). Arrows move by day/week, PageUp/PageDown by month, Enter picks.
import { Calendar } from "@stylhero/ui";
Example
Code
import { useState } from "react";
import { Calendar } from "@stylhero/ui";
function CalendarExample() {
const [day, setDay] = useState<Date | null>(new Date());
return <Calendar value={day} onValueChange={setDay} isDateDisabled={(d) => d.getDay() === 0} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
autoFocus |
boolean |
- | Focus the selected (or today's) day on mount, e.g. inside a popover. |
className |
string |
- | |
isDateDisabled |
(d: Date) => boolean |
- | Return true to block a day (e.g. closed on Sundays). |
locale |
string |
- | BCP 47 locale for month and weekday names, e.g. "es-MX". Defaults to the browser's. |
max |
Date |
- | |
min |
Date |
- | |
mode |
"single" | "range" |
- | |
onValueChange |
((d: Date) => void) | ((r: DateRange) => void) |
- | |
value |
Date | null | DateRange |
- | |
weekStartsOn |
0 | 1 |
0 |
0 = Sunday, 1 = Monday. |
Types
type DateRange = [Date | null, Date | null];
Keyboard
| Key | Does |
|---|---|
| Arrow keys | Move one day (left/right) or one week (up/down). Disabled days are skipped |
| Home / End | First / last day of the week |
| PageUp / PageDown | Previous / next month; with Shift, previous / next year |
| Enter / Space | Picks the focused day |
Accessibility
- A
role="grid"of days with the month as its label. Only one day is in the Tab order; today hasaria-current="date".
Generated from src/components/DatePicker.tsx. Something wrong or missing? Open an issue.