# DateRangePicker

A date range field with a pop-up calendar that works from the keyboard.

- **Use it for**: A date range inside a form or filter bar.
- **Not for**: A large always-visible calendar. Try [Calendar](https://unseenui.com/components/calendar/).

## Installation

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

## Usage

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

<DateRangePicker label="Report period" value={range} onValueChange={setRange}
  month={month} onMonthChange={setMonth} open={open} onOpenChange={setOpen} locale="en-GB" />
```

## Props

- `value` (`DateRange`): Date-only start and end, each nullable while choosing a range.
- `onValueChange` (`(range: DateRange) => void (optional)`): Requests the chosen or cleared range.
- `open` (`boolean`): Whether the calendar popup is visible.
- `onOpenChange` (`(open: boolean) => void`): Accept a requested open or close.
- `month` (`DateOnly`): Controlled displayed month; onMonthChange requests a change.
- `onMonthChange` (`(month: DateOnly) => void`): Update the displayed month.
- `locale` (`string`): Formatting locale. labels and calendarLabels translate the interface text.
- `label` (`string (optional)`): Visible field label. Defaults to the component label.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `calendarLabels` | `Partial<CalendarLabels>` |  |
| `description` | `ReactNode` |  |
| `dir` | `"ltr" \| "rtl"` |  |
| `disabled` | `boolean` |  |
| `disabledDates` | `readonly `${number}-${number}-${number}`[]` |  |
| `error` | `ReactNode` |  |
| `label` | `string` |  |
| `labels` | `Partial<DateRangePickerLabels>` |  |
| `loading` | `boolean` |  |
| `locale` (required) | `string` |  |
| `max` | ``${number}-${number}-${number}`` |  |
| `min` | ``${number}-${number}-${number}`` |  |
| `month` (required) | ``${number}-${number}-${number}`` |  |
| `onMonthChange` (required) | `(month: DateOnly) => void` |  |
| `onOpenChange` (required) | `(open: boolean) => void` |  |
| `onValueChange` | `((value: DateRange) => void)` |  |
| `open` (required) | `boolean` | Disclosure is host-controlled; no selection or close is assumed before acknowledgement. |
| `today` | ``${number}-${number}-${number}`` |  |
| `triggerIcon` | `ReactNode` |  |
| `value` (required) | `DateRange` |  |
| `weekStartsOn` | `0 \| 3 \| 2 \| 1 \| 4 \| 5 \| 6` |  |

## Keyboard

Opening focuses the calendar. Escape closes and returns to the trigger; Clear and Done are labeled actions.

## 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/), [Calendar](https://unseenui.com/components/calendar/), [Select](https://unseenui.com/components/select/)

Page: https://unseenui.com/components/date-range-picker/
