# Date picker

A date field with a calendar.

```vue
<template>
  <NuiDatePicker
    v-model="delivery"
    label="Delivery date"
    description="We deliver the day after payment"
    min="2026-09-27"
    today="2026-09-27"
    clearable
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { NuiDatePicker } from '@numior/kit';

const delivery = ref<string | null>('2026-09-29');
</script>
```

The model holds the date as a `YYYY-MM-DD` string.

## Installation

```ts
import { NuiDatePicker } from '@numior/kit';
```

## Usage

Open the calendar and change the size, the side it opens on and the states of the field.

```vue
<template>
  <NuiDatePicker v-model="delivery" />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { NuiDatePicker } from '@numior/kit';

const delivery = ref<string | null>('2026-09-30');
</script>
```

## Examples

### Pick a date and a time

Add `time`.

```vue
<template>
  <NuiDatePicker
    v-model="courier"
    label="Courier arrival"
    description="The courier calls an hour before arriving"
    time
    :time-step="30"
    today="2026-09-27"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { NuiDatePicker } from '@numior/kit';

const courier = ref<string | null>('2026-09-29T14:30');
</script>
```

Picking a day keeps the calendar open, so the time can be set right away. The model then holds a
string such as `2026-09-29T14:30`.

### Open the calendar on click

Add `openOnClick`.

```vue
<template>
  <NuiDatePicker
    v-model="pickup"
    label="Pickup date"
    description="The order waits at the pickup point for three days"
    min="2026-09-27"
    today="2026-09-27"
    open-on-click
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { NuiDatePicker } from '@numior/kit';

const pickup = ref<string | null>(null);
</script>
```

The caret stays in the field, so the date can still be typed.

## Behavior

- An empty field shows the date pattern of the app language, such as `MM/DD/YYYY`. The field
  adds the separators itself.
- A digit that cannot start a day or a month gets a leading zero: 4 becomes 04.
- A date typed as `2026-10-05` is accepted in any language.
- When the field loses the focus with text that is not a date, the previous value comes back.
- A date before `min`, after `max` or rejected by `isDateDisabled` is accepted neither from the
  keyboard nor in the calendar.

| Keys | Action |
| --- | --- |
| `ArrowDown` | Opens the calendar. When it is open, moves the focus to the selected day. |
| `Escape` | Closes the calendar. |
| `Enter` | In the time field, closes the calendar. |

## API

### NuiDatePicker

```ts
import { NuiDatePicker } from '@numior/kit';
```

#### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `placeholder` | `string` |  | Text shown in the empty field. |
| `name` | `string` |  | The `name` of a hidden input that sends the date with the form in ISO format. |
| `time` | `boolean` | `false` | Adds a time field under the calendar. The value becomes `YYYY-MM-DDTHH:mm`; a date without a time reads as midnight. |
| `timeStep` | `number` | `15` | Minute step when picking the time, such as 15. |
| `timeLabel` | `string` |  | Time button label for screen readers. Defaults to "Choose time" from the dictionary. |
| `locale` | `string` |  | Language, date format and first day of the week. Defaults to `createNuiConfig`. |
| `weekStart` | `Weekday` |  | First day of the week, from 1 (Monday) to 7 (Sunday). Defaults to the locale. |
| `min` | `string` |  | Earliest date that can be selected, January 1, 100 by default. |
| `max` | `string` |  | Latest date that can be selected, December 31, 9999 by default. |
| `isDateDisabled` | `((date: string) => boolean)` |  | Function that disables individual dates, such as weekends. |
| `weekNumbers` | `boolean` | `false` | Shows a week number column in the calendar. |
| `months` | `number` | `1` | How many months the calendar shows side by side. |
| `today` | `string` |  | Today as `YYYY-MM-DD`. Without it the browser clock gives the date after mounting. |
| `clearable` | `boolean` | `false` | Shows a button in the field that clears the date. |
| `openOnClick` | `boolean` | `false` | Opens the calendar on a click in the field. The focus stays there, so the date can still be typed. |
| `placement` | `Placement` | `"bottom-start"` | Where the calendar opens, such as `bottom-start` or `top`. |
| `openLabel` | `string` |  | Calendar button label for screen readers. Defaults to "Choose date" from the dictionary. |
| `clearLabel` | `string` |  | Clear button label for screen readers. Defaults to "Clear" from the dictionary. |
| `dialogLabel` | `string` |  | Calendar popover label for screen readers. Defaults to "Calendar" from the dictionary. |
| `todayLabel` | `string` |  | Text of the "Today" button. Defaults to "Today" from the dictionary. |
| `previousLabel` | `string` |  | Previous month button label for screen readers. Defaults to "Previous month" from the dictionary. |
| `nextLabel` | `string` |  | Next month button label for screen readers. Defaults to "Next month" from the dictionary. |
| `monthLabel` | `string` |  | Month picker button label for screen readers. Defaults to "Choose month" from the dictionary. |
| `yearLabel` | `string` |  | Year picker button label for screen readers. Defaults to "Choose year" from the dictionary. |
| `weekLabel` | `string` |  | Week number column heading for screen readers. Defaults to "Week" from the dictionary. |
| `id` | `string` |  | Id of the control. Defaults to the one from `NuiField` or is generated automatically. |
| `size` | `NuiSize` | `"md"` | Changes the size of the control: `sm`, `md` or `lg`. The theme density shifts the height of each size. |
| `disabled` | `boolean` |  | Disables the control. Inside `NuiField` it defaults to the field value. |
| `readonly` | `boolean` |  | Shows the date without letting it change: typing and the calendar are blocked. |
| `required` | `boolean` |  | Marks the control as required. Inside `NuiField` it defaults to the field value. |
| `invalid` | `boolean` |  | Shows the error state without a text. With `error` it turns on by itself. |
| `label` | `string` |  | Label of the control. Inside `NuiField` the field provides the label. |
| `description` | `string` |  | Hint below the control. Screen readers announce it with the control. |
| `error` | `string` |  | Error text below the control. Puts the control into the error state. |
| `reserveError` | `boolean` | `false` | Reserves space for the error so the form does not shift when it appears. |

#### Models

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model` | `string \| null` | `null` | Date as `YYYY-MM-DD`, with the time when `time` is on. `null` when no date is set. |

#### Slots

| Name | Slot props | Description |
| --- | --- | --- |
| `actions` | `any` | Buttons under the calendar next to "Today". |

#### Exposed

| Name | Type | Description |
| --- | --- | --- |
| `focus` | `() => void` | Moves the focus into the field. |
| `open` | `() => void` | Opens the calendar and moves the focus into it. |
| `close` | `() => void` | Closes the calendar without returning the focus to the field. |

#### Texts

| Key | Text |
| --- | --- |
| `clear` | Clear |
| `dayGlyph` | D |
| `dialog` | Calendar |
| `end` | End date |
| `monthGlyph` | M |
| `open` | Choose date |
| `openRange` | Choose dates |
| `timeGlyphs` | HH:mm |
| `yearGlyph` | Y |
