[ Forms ]
Calendar
A month grid with month and year pickers, single or range selection, a today marker and arrow-key navigation.
3 examplesDark modeAccessible
Import#
import { Calendar } from 'reusify-ui';When to use#
- Inline date or date-range picking, such as scheduling or booking.
- Use an Input with type="date" for a compact field inside a long form.
Examples#
Single date#
No date selected
const [date, setDate] = useState(null);
<Calendar value={date} onChange={setDate} />Range#
mode="range" picks a start and then an end date. The value is { start, end }, and end is null until the second click. Picking an earlier day swaps the ends.
… – …
const [range, setRange] = useState({ start: null, end: null });
<Calendar mode="range" value={range} onChange={setRange} color="#2563eb" />Week start and colors#
weekStartsOn takes 0 (Sunday) to 6. color accepts a semantic name or any CSS color.
<Calendar weekStartsOn={0} color="success" defaultValue={new Date()} />Used in designs#
Calendar in real layouts: this design uses it. Open one to try it and copy the code.
API reference#
<Calendar />
| Prop | Type | Default | Description |
|---|---|---|---|
mode | 'single' | 'range' | 'single' | Selection mode. |
value / defaultValue | Date | { start, end } | - | Controlled / initial selection. |
onChange | (value) => void | - | Called with the new Date or { start, end }. |
defaultMonth | Date | - | Month shown first. Defaults to the selection or today. |
weekStartsOn | 0–6 | 1 | First day of the week (0 = Sunday). |
minYear / maxYear | number | ±10 years | Range of the year picker. |
color | semantic | string | 'primary' | Selection and today-dot color. |
today | Date | new Date() | Date marked as today. |
mode'single''single' | 'range'Selection mode.
value / defaultValue-Date | { start, end }Controlled / initial selection.
onChange-(value) => voidCalled with the new Date or { start, end }.
defaultMonth-DateMonth shown first. Defaults to the selection or today.
weekStartsOn10–6First day of the week (0 = Sunday).
minYear / maxYear±10 yearsnumberRange of the year picker.
color'primary'semantic | stringSelection and today-dot color.
todaynew Date()DateDate marked as today.
Accessibility#
- Each day is a button with its full date as the accessible name, aria-pressed when selected and aria-current="date" for today.
- Arrow keys move focus by day and by week.
- The month and year pickers are labelled Selects.