# Date Picker

> Source: https://design.nanatec.co.ke/components/date-picker/
> A form field for one date — a move-in date, a due date — that opens a calendar under the field. The value is `yyyy-mm-dd` and is what the form submits.
> Status: beta
> Since: v0.0.40

The calendar takes focus when it opens, so the arrow keys work at once;
Escape or a click outside closes it and returns focus to the field.

## Preview

## Months and years far away

The month and year at the top of the calendar are lists: choose a year to jump
straight to it. Without bounds the years run from a hundred years back to twenty
ahead; set `min` and `max` to narrow them.

```html
<div style="min-height:24rem">
  <nana-date-picker label="Tenant's date of birth" max="2008-12-31" value="1990-07-15"></nana-date-picker>
</div>
```

## Bounds and refused days

`min` and `max` put days out of reach entirely. `isDateDisabled` refuses days by
rule — here weekends — while still letting the keyboard move across them.

```html
<div style="min-height:24rem">
  <nana-date-picker id="viewing" label="Viewing day" min="2026-03-02" max="2026-04-30" value="2026-03-11"></nana-date-picker>
</div>
```

```js
document.getElementById("viewing").isDateDisabled = (iso) =>
  [0, 6].includes(new Date(`${iso}T00:00`).getDay());
```

## Installation

```html
<nana-date-picker label="Move-in date" name="moveIn" min="2026-03-01" required></nana-date-picker>
```

```js
const el = document.querySelector("nana-date-picker");
el.addEventListener("nana-change", (e) => console.log(e.detail));
el.addEventListener("nana-focus", (e) => console.log(e.detail));
el.addEventListener("nana-blur", (e) => console.log(e.detail));
```

The calendar opens below the field, or above with `placement="top-start"`. When
the preferred side has no room it flips to the other, the same way the select and
combobox do, so a field near the bottom of the screen still shows the whole month.
