<!--
Source: https://www.theui.dev/docs/date-picker
Part of the theui-svelte documentation. Index: https://www.theui.dev/llms.txt
-->

# Date Picker

The DatePicker component opens a calendar under the field and gives back the chosen day. The value is a plain YYYY-MM-DD string, so it submits with a form and travels to a server without any date library. The calendar follows the Material style: circular days, a month and year list, and a today and clear action.

## Example

Import the component and bind a string. Click the field to open the calendar.

```html
<script>
  import { DatePicker } from "theui-svelte";
  let date = $state("")
</script>

<DatePicker bind:value={date} placeholder="Pick a date">Birthday</DatePicker>
```

## Limits and Disabled Days

Use `min` and `max`, both ISO dates, to fence the calendar in. For anything else, `disabledDates` is asked about each day and returns `true` for the ones to turn off, such as weekends or days that are already taken.

```html
<DatePicker
  bind:value={meeting}
  min="2026-01-01"
  max="2026-12-31"
  disabledDates={(date) => date.getDay() === 5 || date.getDay() === 6}
>Meeting day</DatePicker>
```

## Locale and First Day

The `locale` prop decides the language of the month and weekday names and how the value is shown, and `firstDayOfWeek` sets which day starts the week, where `0` is Sunday and `1` is Monday. Both use the browser's own date formatting, so nothing extra is loaded.

```html
<DatePicker value="2026-03-14" locale="en-GB" firstDayOfWeek={1} />
<DatePicker value="2026-03-14" locale="de-DE" firstDayOfWeek={1} />
<DatePicker value="2026-03-14" locale="bn-BD" />
```

## Display Format

By default the date is shown in a medium style for the locale. Pass `format` to write it your own way. The value itself never changes, only what is read in the field.

```html
<DatePicker value="2026-03-14" />
<DatePicker value="2026-03-14" format={(d) => d.toLocaleDateString("en-US", {dateStyle: "full"})} />
<DatePicker value="2026-03-14" format={(d) => `${d.getDate()}/${d.getMonth() + 1}/${d.getFullYear()}`} />
```

## Typing a Date

The field is read-only by default, so a tap opens the calendar. Add `editable` to let the date be typed as well. Typing takes the ISO form, `YYYY-MM-DD`, and anything else is put back when the field loses focus.

```html
<DatePicker bind:value={date} editable placeholder="YYYY-MM-DD">Typed date</DatePicker>
```

## Inline Calendar

With `inline` the calendar is always open and there is no field, which suits a booking page or a filter panel.

```html
<DatePicker bind:value={date} inline>Choose a day</DatePicker>
```

## Footer Actions

The calendar has a **Today** button and, once a date is chosen, a **Clear** button. Turn the first off with `showToday={false}` and the second with `clearable={false}`, or rename them with `todayText` and `clearText`.

```html
<DatePicker value="2026-03-14" todayText="Jump to today" clearText="Remove" />
<DatePicker value="2026-03-14" showToday={false} clearable={false} />
```

## In a Form

Give the component a `name` and the ISO value is submitted, which is the form every backend understands. The `onchange` callback runs with the new value.

```html
<form method="POST">
  <DatePicker name="startDate" value="2026-03-14" onchange={(v) => console.log(v)}>
    Start date
  </DatePicker>
  <button>Save</button>
</form>
```

## Animation Speed

The `animationSpeed` prop sets how quickly the field and the calendar react to focus, hover and opening. It takes `"none"`, `"slower"`, `"slow"`, `"normal"`, `"fast"` and `"faster"`, and the default is `"normal"`. Inside a [Form](https://www.theui.dev/docs/form) or a [Fieldset](https://www.theui.dev/docs/fieldset) the value is inherited, so one setting covers every field at once.

```html
<DatePicker animationSpeed="slower" placeholder="Slower" />
<DatePicker animationSpeed="normal" placeholder="Normal" />
<DatePicker animationSpeed="faster" placeholder="Faster" />
<DatePicker animationSpeed="none" placeholder="No animation" />
```

## Reset Styles

Set `reset` to `true` to drop the border, background and focus ring of the field and keep only the classes you pass. The calendar panel keeps its own styling, so only the closed field changes. The default is `false`, and a [Form](https://www.theui.dev/docs/form) or a [Fieldset](https://www.theui.dev/docs/fieldset) can set it for every field it holds.

```html
<DatePicker
  reset
  class="w-full border-b-2 border-gray-400 px-1 py-2"
  placeholder="Underline only" />
```

## Customization

Sizes and variants come from the [Form](https://www.theui.dev/docs/form) or the [Fieldset](https://www.theui.dev/docs/fieldset), or from the props here. Use `panelClass` for the calendar, `dayClasses` for every day and `selectedDayClasses` for the chosen one.

```html
<DatePicker value="2026-03-14" size="lg" variant="flat" />
<DatePicker value="2026-03-14" selectedDayClasses="bg-info-500 hover:bg-info-600" />
<DatePicker value="2026-03-14" dayClasses="rounded-lg" />
```

## Keyboard

In the field, the down arrow or Enter opens the calendar. Inside it, the arrow keys move a day at a time, Page Up and Page Down move a month, with Shift a year, Home and End go to the start and end of the week, Enter or Space takes the day, and Escape closes and puts the focus back on the field. Only one day is in the tab order at a time, so Tab leaves the calendar instead of walking through forty-two buttons.

## Accessibility

The calendar is a dialog with a grid inside it, the pattern screen readers know. Each day is a button named in full, such as "Saturday, 14 March 2026", so the number is never read alone; today is marked with `aria-current` and the chosen day with `aria-selected`. The month in view is announced politely as it changes, and days outside the range are disabled rather than hidden. The month and year button opens a list of years and months, so a distant date takes a few clicks instead of many. The panel is positioned with a fixed strategy, so it stays on screen inside scrolling boxes.

## Configuration

### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | string | `` | The chosen date as "YYYY-MM-DD". Bindable with `bind:value`. |
| `min` | string | `undefined` | Earliest date that can be chosen, as "YYYY-MM-DD". |
| `max` | string | `undefined` | Latest date that can be chosen, as "YYYY-MM-DD". |
| `disabledDates` | (date: Date) => boolean | `undefined` | Asked about every day in the calendar. Return true to turn that day off. |
| `firstDayOfWeek` | number | `0` | Day the week starts on, where 0 is Sunday and 1 is Monday. |
| `locale` | string | `undefined` | Language of the month and weekday names, and of the shown value. Defaults to the browser's own. |
| `format` | (date: Date) => string | `medium date of the locale` | Turns the chosen date into the text shown in the field. |
| `editable` | boolean | `false` | Lets the date be typed into the field, in the ISO form "YYYY-MM-DD". |
| `inline` | boolean | `false` | Shows the calendar in the page instead of in a popup. |
| `clearable` | boolean | `true` | Shows the clear button in the field and in the calendar footer. |
| `showToday` | boolean | `true` | Shows the today button in the calendar footer. |
| `todayText` | string | `Today` | Text of the today button. |
| `clearText` | string | `Clear` | Text of the clear button in the footer. |
| `openLabel` | string | `Choose date` | Accessible name of the calendar button and of the calendar itself. |
| `placeholder` | string | `` | Placeholder of the field while no date is picked. |
| `onchange` | (value: string) => void | `undefined` | Runs with the new value every time the date changes. |
| `name` | string | `undefined` | Name of the field, so the ISO value is submitted with the form. |
| `size` | [INPUT_SIZE](https://www.theui.dev/docs/types#input-size-type) | `md` | Size of the field. Inherited from Form or Fieldset. |
| `variant` | [INPUT_VARIANT](https://www.theui.dev/docs/types#input-variant-type) | `bordered` | Style of the field: "bordered" or "flat". Inherited from Form or Fieldset. |
| `animationSpeed` | [ANIMATE_SPEED](https://www.theui.dev/docs/types#animation-speed-type) | `Inherited from Fieldset or Form, or "normal` | Defines the animation speed for transitions. Available options: "none", "slower", "slow", "normal", "fast", "faster". |
| `reset` | boolean | `Inherited from Fieldset or Form, or false` | Resets all default styles and applies only custom styles. |
| `rounded` | [ROUNDED](https://www.theui.dev/docs/types#rounded-type) | `md` | Defines the border radius of the field. |
| `helperText` | string \| Snippet | `undefined` | Text under the field, linked to the input for screen readers. |
| `labelClasses` | string | `` | Custom classes for the label. |
| `wrapperClasses` | string | `` | Custom classes for the field wrapper. |
| `panelClass` | string | `` | Custom classes for the calendar panel. |
| `dayClasses` | string | `` | Custom classes for every day in the grid. |
| `selectedDayClasses` | string | `` | Custom classes added to the chosen day. |

### Dynamic props

| Name | Description |
| --- | --- |
| `class` | Classes passed to the field, merged with the default classes. |
| `disabled` | Switches the field off, so the calendar cannot be opened. |
| `readonly` | Shows the date without letting anyone change it. |

### Snippets

| Name | Description |
| --- | --- |
| `children` | Label of the field. |

---

Category: Forms
Keywords: date picker, calendar, date input, form, svelte, svelte-5, theui-svelte, component-library, ui, tailwindcss
Full documentation set: https://www.theui.dev/llms-full.txt
