# Calendar

Pick a date or a range, in any language, limited to the dates you allow.

- **Use it for**: Picking a date or range inline, with availability rules.
- **Not for**: A compact field in a form. Try [DateRangePicker](https://unseenui.com/components/date-range-picker/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Calendar } from '@stackunseen/ui/application';
import '@stackunseen/ui/styles.css';
import '@stackunseen/ui/application.css';

<Calendar value={date} onValueChange={setDate} month={month} onMonthChange={setMonth}
  locale="en-GB" min="2026-10-01" max="2026-12-31" />
```

## Props

- `mode` (`'single' | 'range' (optional)`): Select one date by default, or a start/end range.
- `value` (`DateOnly | null, or DateRange`): Controlled selection matching mode.
- `onValueChange` (`(selection) => void (optional)`): Requests a selection. An earlier range end restarts the range; a disabled interior day blocks completion.
- `month` (`DateOnly`): Any valid date in the displayed month.
- `onMonthChange` (`(month: DateOnly) => void`): Requests the first day of the next displayed month.
- `locale` (`string`): Date and weekday formatting locale. Use labels to translate interface wording.
- `today` (`DateOnly (optional)`): Today’s date from your app. The browser’s clock and time zone aren’t used.
- `disabledDates` (`readonly DateOnly[] (optional)`): Unavailable dates. min and max provide inclusive date bounds.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `dir` | `"ltr" \| "rtl"` |  |
| `disabled` | `boolean` |  |
| `disabledDates` | `readonly `${number}-${number}-${number}`[]` |  |
| `error` | `ReactNode` |  |
| `label` | `string` |  |
| `labels` | `Partial<CalendarLabels>` |  |
| `loading` | `boolean` |  |
| `locale` (required) | `string` | Required locale formats dates/weekdays; use labels to translate interface text. |
| `max` | ``${number}-${number}-${number}`` |  |
| `min` | ``${number}-${number}-${number}`` |  |
| `mode` | `"single" \| undefined \| "range"` |  |
| `month` (required) | ``${number}-${number}-${number}`` | Any valid date in the displayed month. |
| `nextIcon` | `ReactNode` |  |
| `onMonthChange` (required) | `(month: DateOnly) => void` |  |
| `onValueChange` | `((value: DateOnly) => void) \| undefined \| ((value: DateRange) => void)` | An intent only; selection changes when the host updates value. |
| `previousIcon` | `ReactNode` |  |
| `today` | ``${number}-${number}-${number}`` | Supplied by the host to avoid implicit clock/timezone and hydration differences. |
| `value` (required) | ``${number}-${number}-${number}` \| null \| DateRange` |  |
| `weekStartsOn` | `0 \| 3 \| 2 \| 1 \| 4 \| 5 \| 6` | 0 = Sunday, 1 = Monday, ... |

## Keyboard

Arrow keys move by day or week, Home/End by week and Page Up/Down by month. Enter or Space selects an available day.

## Works with

[Field](https://unseenui.com/components/field/), [Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Checkbox](https://unseenui.com/components/checkbox/), [Switch](https://unseenui.com/components/switch/), [RadioGroup](https://unseenui.com/components/radio-group/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Combobox](https://unseenui.com/components/combobox/), [DateRangePicker](https://unseenui.com/components/date-range-picker/), [Select](https://unseenui.com/components/select/)

Page: https://unseenui.com/components/calendar/
