[ 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 />

mode'single'
'single' | 'range'

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.

weekStartsOn1
0–6

First day of the week (0 = Sunday).

minYear / maxYear±10 years
number

Range of the year picker.

color'primary'
semantic | string

Selection and today-dot color.

todaynew Date()
Date

Date 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.