---
title: "Date Picker"
description: "Facilitates the selection of dates through an input and calendar-based interface."
canonical_url: "https://vinicunca.dev/akar/components/date-picker"
---
# Date Picker

> Facilitates the selection of dates through an input and calendar-based interface.

`````vue [index.vue]
<script setup lang="ts">
import {
  DatePickerArrow,
  DatePickerCalendar,
  DatePickerCell,
  DatePickerCellTrigger,
  DatePickerContent,
  DatePickerField,
  DatePickerGrid,
  DatePickerGridBody,
  DatePickerGridHead,
  DatePickerGridRow,
  DatePickerHeadCell,
  DatePickerHeader,
  DatePickerHeading,
  DatePickerInput,
  DatePickerNext,
  DatePickerPrev,
  DatePickerRoot,
  DatePickerTrigger,
  Label,
} from 'akar'

import './styles.css'
</script>

<template>
  <div class="akar-demo akar-demo-DatePicker">
    <div class="DateFieldWrapper">
        <Label
          class="DateFieldLabel"
          for="date-field"
        >Birthday</Label>
        <DatePickerRoot
          id="date-field"
          :is-date-unavailable="date => date.day === 19"
          granularity="second"
        >
          <DatePickerField
            v-slot="{ segments }"
            class="DateField"
          >
            <template
              v-for="item in segments"
              :key="item.part"
            >
              <DatePickerInput
                v-if="item.part === 'literal'"
                :part="item.part"
                class="DateFieldLiteral"
              >
                {{ item.value }}
              </DatePickerInput>
              <DatePickerInput
                v-else
                :part="item.part"
                class="DateFieldSegment"
              >
                {{ item.value }}
              </DatePickerInput>
            </template>

            <DatePickerTrigger class="PopoverTrigger">
              <PIcon
                name="i-lucide-calendar"
                class="Icon"
              />
            </DatePickerTrigger>
          </DatePickerField>

          <DatePickerContent
            align="end"
            :side-offset="16"
            class="PopoverContent"
          >
            <DatePickerArrow class="PopoverArrow" />
            <DatePickerCalendar
              v-slot="{ weekDays, grid }"
              class="Calendar"
            >
              <DatePickerHeader class="CalendarHeader">
                <DatePickerPrev
                  class="CalendarNavButton"
                >
                  <PIcon
                    name="i-lucide-chevron-left"
                    class="Icon"
                  />
                </DatePickerPrev>

                <DatePickerHeading class="CalendarHeading" />
                <DatePickerNext
                  class="CalendarNavButton"
                >
                  <PIcon
                    name="i-lucide-chevron-right"
                    class="Icon"
                  />
                </DatePickerNext>
              </DatePickerHeader>
              <div
                class="CalendarWrapper"
              >
                <DatePickerGrid
                  v-for="month in grid"
                  :key="month.value.toString()"
                  class="CalendarGrid"
                >
                  <DatePickerGridHead>
                    <DatePickerGridRow class="CalendarGridRow">
                      <DatePickerHeadCell
                        v-for="day in weekDays"
                        :key="day"
                        class="CalendarHeadCell"
                      >
                        {{ day }}
                      </DatePickerHeadCell>
                    </DatePickerGridRow>
                  </DatePickerGridHead>
                  <DatePickerGridBody>
                    <DatePickerGridRow
                      v-for="(weekDates, index) in month.rows"
                      :key="`weekDate-${index}`"
                      class="CalendarGridRow"
                    >
                      <DatePickerCell
                        v-for="weekDate in weekDates"
                        :key="weekDate.toString()"
                        :date="weekDate"
                        class="CalendarCell"
                      >
                        <DatePickerCellTrigger
                          :day="weekDate"
                          :month="month.value"
                          class="CalendarCellTrigger"
                        />
                      </DatePickerCell>
                    </DatePickerGridRow>
                  </DatePickerGridBody>
                </DatePickerGrid>
              </div>
            </DatePickerCalendar>
          </DatePickerContent>
        </DatePickerRoot>
      </div>
  </div>
</template>
```

```css [styles.css]
@import '../_colors/black-alpha.css';
@import '../_colors/mauve.css';
@import '../_colors/grass.css';

@scope (.akar-demo-DatePicker) {
.DateFieldWrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.DateFieldLabel {
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--gray-9);
}

.DateField {
  display: flex;
  padding: 0.5rem;
  align-items: center;
  border-radius: 0.25rem;
  border-width: 1px;
  text-align: center;
  background-color: #ffffff;
  user-select: none;
  color: var(--green-10);
  border: 1px solid var(--gray-9);
}

.DateField::placeholder {
  color: var(--mauve-5);
}

.DateField[data-invalid] {
  border: 1px solid var(--red-500);
}

.DateFieldLiteral {
  padding: 0.25rem;
}

.DateFieldSegment {
  padding: 0.25rem;
}

.DateFieldSegment:hover{
  background-color: var(--grass-4);
}

.DateFieldSegment:focus {
  background-color: var(--grass-2);
}

.DateFieldSegment:[aria-valuetext='Empty'] {
  color: var(--grass-6);
}

.Icon {
  width: 1.5rem;
  height: 1.5rem;
}

.Calendar {
  padding: 22px;
}

.CalendarHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.CalendarNavButton {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 2.5rem;
  height: 2.5rem;
  color: #000000;
  background-color: transparent;
  cursor: pointer;
}

.CalendarNavButton:hover {
  color: #ffffff;
  background-color: #000000;
}

.CalendarHeading {
  font-weight: 500;
  color: #000000;
  color: 15px;
}

.CalendarWrapper {
  display: flex;
  padding-top: 1rem;
  margin-top: 1rem;
  flex-direction: column;
}

@media (min-width: 640px) {
  .CalendarWrapper {
    margin-left: 1rem;
    margin-top: 0;
    flex-direction: row;
  }
}

.CalendarGrid {
  margin-top: 0.25rem;
  width: 100%;
  user-select: none;
  border-collapse: collapse;
}

.CalendarGridRow {
  display: grid;
  margin-bottom: 0.25rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
}

.CalendarGridRow[data-reka-calendar-month-view] {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.CalendarHeadCell {
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: #000000;
  font-weight: 400;
}

.CalendarCell {
  position: relative;
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-align: center;
}

.CalendarCellTrigger {
  display: flex;
  position: relative;
  padding: 0.5rem;
  justify-content: center;
  align-items: center;
  border-width: 1px;
  border-color: transparent;
  outline-style: none;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  color: #000000;
  white-space: nowrap;
  background-color: transparent;
}

.CalendarCellTrigger:hover {
  border-color: #000000;
}

.CalendarCellTrigger:focus {
  box-shadow: 0 0 0 2px #000000;
}

.CalendarCellTrigger[data-disabled] {
  cursor: none;
  color: rgba(0,0,0,0.3);
}

.CalendarCellTrigger[data-selected] {
  background-color: #000000;
  color: #ffffff;
  font-weight: 500;
}

.CalendarCellTrigger[data-selected]::before {
  background-color: #FFFFFF;
}

.CalendarCellTrigger[data-unavailable] {
  color: rgba(0,0,0,0.3);
  text-decoration: line-through;
}

.CalendarCellTrigger::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 0;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 9999px;
  background-color: #FFFFFF;
}

.CalendarCellTrigger[data-today]::before {
  display: block;
  background-color: var(--grass-9);
}

.PopoverTrigger:focus {
  box-shadow: 0 0 0 2px #000000;
}

.PopoverContent {
  border-radius: 4px;
  padding: 20px;
  width: 260px;
  background-color: white;
  box-shadow: hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
  animation-duration: 400ms;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}
.PopoverContent:focus {
  box-shadow: hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px,
    0 0 0 2px var(--grass-7);
}
.PopoverContent[data-state='open'][data-side='top'] {
  animation-name: slideDownAndFade;
}
.PopoverContent[data-state='open'][data-side='right'] {
  animation-name: slideLeftAndFade;
}
.PopoverContent[data-state='open'][data-side='bottom'] {
  animation-name: slideUpAndFade;
}
.PopoverContent[data-state='open'][data-side='left'] {
  animation-name: slideRightAndFade;
}

.PopoverArrow {
  fill: white;
}

@keyframes slideUpAndFade {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideRightAndFade {
  from {
    opacity: 0;
    transform: translateX(-2px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideDownAndFade {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideLeftAndFade {
  from {
    opacity: 0;
    transform: translateX(2px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
}
```

## Features

- Full keyboard navigation
- Can be controlled or uncontrolled
- Focus is fully managed
- Localization support
- Accessible by default
- Supports both date and date-time formats

## Preface

The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript.

We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components.

## Installation

Install the date package.

```bash [pnpm]
pnpm add @internationalized/date
```

```bash [yarn]
yarn add @internationalized/date
```

```bash [npm]
npm install @internationalized/date
```

```bash [bun]
bun add @internationalized/date
```

Install the component from your command line.

```bash [pnpm]
pnpm add akar
```

```bash [yarn]
yarn add akar
```

```bash [npm]
npm install akar
```

```bash [bun]
bun add akar
```

## Anatomy

Import all parts and piece them together.

```vue
<script setup>
import {
  DatePickerAnchor,
  DatePickerArrow,
  DatePickerCalendar,
  DatePickerCell,
  DatePickerCellTrigger,
  DatePickerClose,
  DatePickerContent,
  DatePickerField,
  DatePickerGrid,
  DatePickerGridBody,
  DatePickerGridHead,
  DatePickerGridRow,
  DatePickerHeadCell,
  DatePickerHeader,
  DatePickerHeading,
  DatePickerInput,
  DatePickerNext,
  DatePickerPrev,
  DatePickerRoot,
  DatePickerTrigger,
} from 'akar';
</script>

<template>
  <DatePickerRoot>
    <DatePickerField>
      <DatePickerInput />
      <DatePickerTrigger />
    </DatePickerField>

    <DatePickerAnchor />
    <DatePickerContent>
      <DatePickerClose />
      <DatePickerArrow />

      <DatePickerCalendar>
        <DatePickerHeader>
          <DatePickerPrev />
          <DatePickerHeading />
          <DatePickerNext />
        </DatePickerHeader>

        <DatePickerGrid>
          <DatePickerGridHead>
            <DatePickerGridRow>
              <DatePickerHeadCell />
            </DatePickerGridRow>
          </DatePickerGridHead>

          <DatePickerGridBody>
            <DatePickerGridRow>
              <DatePickerCell>
                <DatePickerCellTrigger />
              </DatePickerCell>
            </DatePickerGridRow>
          </DatePickerGridBody>
        </DatePickerGrid>
      </DatePickerCalendar>
    </DatePickerContent>
  </DatePickerRoot>
</template>
```

## API Reference

### Root

Contains all the parts of a date picker

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `closeOnSelect` | `false` | `boolean` | Whether or not to close the popover on date select |
| `defaultOpen` | `false` | `boolean` | The open state of the popover when it is initially rendered. Use when you do not need to control its open state. |
| `defaultPlaceholder` |  | `DateValue` | The default placeholder date |
| `defaultValue` |  | `DateValue` | The default value for the calendar |
| `dir` |  | `"ltr" \| "rtl"` | The reading direction of the date field when applicable.<br><br>If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. |
| `disabled` | `false` | `boolean` | Whether or not the date field is disabled |
| `fixedWeeks` | `false` | `boolean` | Whether or not to always display 6 weeks in the calendar |
| `granularity` |  | `"day" \| "hour" \| "minute" \| "second"` | The granularity to use for formatting times. Defaults to day if a CalendarDate is provided, otherwise defaults to minute. The field will render segments for each part of the date up to and including the specified granularity |
| `hideTimeZone` |  | `boolean` | Whether or not to hide the time zone segment of the field |
| `hourCycle` |  | `12 \| 24` | The hour cycle used for formatting times. Defaults to the local preference |
| `id` |  | `string` | Id of the element |
| `isDateDisabled` |  | `Matcher` | A function that returns whether or not a date is disabled |
| `isDateUnavailable` |  | `Matcher` | A function that returns whether or not a date is unavailable |
| `locale` |  | `string` | The locale to use for formatting dates |
| `maxValue` |  | `DateValue` | The maximum date that can be selected |
| `minValue` |  | `DateValue` | The minimum date that can be selected |
| `modal` | `false` | `boolean` | The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers. |
| `modelValue` |  | `DateValue \| null` | The controlled value of the field. Can be bound as `v-model`. |
| `name` |  | `string` | The name of the field. Submitted with its owning form as part of a name/value pair. |
| `numberOfMonths` | `1` | `number` | The number of months to display at once |
| `open` |  | `boolean` | The controlled open state of the popover. |
| `pagedNavigation` | `false` | `boolean` | This property causes the previous and next buttons to navigate by the number of months displayed at once, rather than one month |
| `placeholder` |  | `DateValue` | The placeholder date, which is used to determine what month to display when no date is selected. This updates as the user navigates the calendar and can be used to programmatically control the calendar view |
| `preventDeselect` | `false` | `boolean` | Whether or not to prevent the user from deselecting a date without selecting another date first |
| `readonly` | `false` | `boolean` | Whether or not the date field is readonly |
| `required` |  | `boolean` | When `true`, indicates that the user must set the value before the owning form can be submitted. |
| `step` |  | `DateStep` | The stepping interval for the time fields. Defaults to `1`. |
| `stepSnapping` |  | `boolean` | Whether to enforce snapping the time value to the nearest step increment after input. Defaults to `false`. |
| `weekdayFormat` | `"narrow"` | `"narrow" \| "short" \| "long"` | The format to use for the weekday strings provided via the weekdays slot prop |
| `weekStartsOn` |  | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` | The day of the week to start the calendar on |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `update:modelValue` | `date: DateValue` | Event handler called whenever the model value changes |
| `update:open` | `value: boolean` | Event handler called when the open state of the popover changes. |
| `update:placeholder` | `date: DateValue` | Event handler called whenever the placeholder value changes |

[DatePickerRoot.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerRoot.vue)

### Field

Contains the date picker date field segments and trigger

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `segments` | `{ part: SegmentPart; value: string; }[]` |  |
| `modelValue` | `DateValue` |  |

[DatePickerField.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerField.vue)

| Data attribute | Value |
| --- | --- |
| `[data-readonly]` | Present when readonly |
| `[data-disabled]` | Present when disabled |
| `[data-invalid]` | Present when invalid |

### Input

Contains the date picker date field segments

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `part*` |  | `"day" \| "month" \| "year" \| "hour" \| "minute" \| "second" \| "dayPeriod" \| "literal" \| "timeZoneName"` | The part of the date to render |

[DatePickerInput.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerInput.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |
| `[data-invalid]` | Present when invalid |
| `[data-placeholder]` | Present when no value is set |

### Trigger

The button that toggles the popover. By default, the `DatePickerContent` will position itself against the trigger.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerTrigger.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerTrigger.vue)

### Content

The component that pops out when the popover is open.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `align` | `"center"` | `"start" \| "center" \| "end"` | The preferred alignment against the trigger.<br>May change when collisions occur. |
| `alignFlip` | `true` | `boolean` | Flip alignment when colliding with boundary.<br>May only occur when `prioritizePosition` is true. |
| `alignOffset` | `0` | `number` | An offset in pixels from the `start` or `end` alignment options. |
| `arrowPadding` | `0` | `number` | The padding between the arrow and the edges of the content.<br>If your content has border-radius, this will prevent it from<br>overflowing the corners. |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `avoidCollisions` | `true` | `boolean` | When `true`, overrides the side and align preferences<br>to prevent collisions with boundary edges. |
| `collisionBoundary` | `[]` | `Element \| (Element \| null)[] \| null` | The element used as the collision boundary. By default<br>this is the viewport, though you can provide additional<br>element(s) to be included in this check. |
| `collisionPadding` | `0` | `number \| Partial<Record<"top" \| "right" \| "bottom" \| "left", number>>` | The distance in pixels from the boundary edges where collision<br>detection should occur. Accepts a number (same for all sides),<br>or a partial padding object, for example: { top: 20, left: 20 }. |
| `dir` |  | `"ltr" \| "rtl"` | The reading direction of the popper content when applicable.<br><br>If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. |
| `disableOutsidePointerEvents` |  | `boolean` | When `true`, hover/focus/click interactions will be disabled on elements outside<br>the `DismissableLayer`. Users will need to click twice on outside elements to<br>interact with them: once to close the `DismissableLayer`, and again to trigger the element. |
| `disableUpdateOnLayoutShift` | `false` | `boolean` | Whether to disable the update position for the content when the layout shifted. |
| `forceMount` |  | `boolean` | Used to force mounting when more control is needed. Useful when<br>controlling animation with Vue animation libraries. |
| `hideShiftedArrow` | `true` | `boolean` | When `true`, hides the arrow when it cannot be centered<br>to the reference element. |
| `hideWhenDetached` | `false` | `boolean` | Whether to hide the content when the trigger becomes fully occluded. |
| `memoDependencies` |  | `unknown[]` | Reactive dependencies that should invalidate the memoized content subtree. |
| `portal` |  | `PopoverPortalProps` | Props to control the portal wrapped around the content. |
| `positionStrategy` |  | `"fixed" \| "absolute"` | The type of CSS position property to use. |
| `prioritizePosition` | `false` | `boolean` | Force content to be position within the viewport.<br><br>Might overlap the reference element, which may not be desired. |
| `reference` |  | `ReferenceElement` | The custom element or virtual element that will be set as the reference<br>to position the floating element.<br><br>If provided, it will replace the default anchor element. |
| `side` | `"bottom"` | `"top" \| "right" \| "bottom" \| "left"` | The preferred side of the trigger to render against when open.<br>Will be reversed when collisions occur and avoidCollisions<br>is enabled. |
| `sideFlip` | `true` | `boolean` | Flip to the opposite side when colliding with boundary. |
| `sideOffset` | `0` | `number` | The distance in pixels from the trigger. |
| `sticky` | `"partial"` | `"partial" \| "always"` | The sticky behavior on the align axis. `partial` will keep the<br>content in the boundary as long as the trigger is at least partially<br>in the boundary whilst "always" will keep the content in the boundary<br>regardless. |
| `updatePositionStrategy` | `'optimized'` | `"always" \| "optimized"` | Strategy to update the position of the floating element on every animation frame. |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `closeAutoFocus` | `event: Event` | Event handler called when auto-focusing on close.<br>Can be prevented. |
| `escapeKeyDown` | `event: KeyboardEvent` | Event handler called when the escape key is down.<br>Can be prevented. |
| `focusOutside` | `event: FocusOutsideEvent` | Event handler called when the focus moves outside of the `DismissableLayer`.<br>Can be prevented. |
| `interactOutside` | `event: PointerDownOutsideEvent \| FocusOutsideEvent` | Event handler called when an interaction happens outside the `DismissableLayer`.<br>Specifically, when a `pointerdown` event happens outside or focus moves outside of it.<br>Can be prevented. |
| `openAutoFocus` | `event: Event` | Event handler called when auto-focusing on open.<br>Can be prevented. |
| `pointerDownOutside` | `event: PointerDownOutsideEvent` | Event handler called when a `pointerdown` event happens outside of the `DismissableLayer`.<br>Can be prevented. |

[DatePickerContent.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerContent.vue)

### Arrow

An optional arrow element to render alongside the popover. This can be used to help visually link the anchor with the `DatePickerContent`. Must be rendered inside `DatePickerContent`.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `height` | `5` | `number` | The height of the arrow in pixels. |
| `rounded` | `false` | `boolean` | When `true`, render the rounded version of arrow. Do not work with `as`/`asChild` |
| `width` | `10` | `number` | The width of the arrow in pixels. |

[DatePickerArrow.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerArrow.vue)

### Close

The button that closes an open date picker.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerClose.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerClose.vue)

### Anchor

An optional element to position the `DatePickerContent` against. If this part is not used, the content will position alongside the `DatePickerTrigger`.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `reference` |  | `ReferenceElement` | The reference (or anchor) element that is being referred to for positioning.<br><br>If not provided will use the current component as anchor. |

[DatePickerAnchor.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerAnchor.vue)

### Calendar

Contains all the parts of a calendar

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `date` | `DateValue` |  |
| `grid` | `Grid<DateValue>[]` |  |
| `weekDays` | `string[]` |  |
| `weekStartsOn` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` |  |
| `locale` | `string` |  |
| `fixedWeeks` | `boolean` |  |

[DatePickerCalendar.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerCalendar.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |
| `[data-invalid]` | Present when invalid |
| `[data-readonly]` | Present when readonly |

### Header

Contains the navigation buttons and the heading segments.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerHeader.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerHeader.vue)

### Prev Button

Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `prevPage` |  | `((placeholder: DateValue) => DateValue)` | The function to be used for the prev page. Overwrites the `prevPage` function set on the `CalendarRoot`. |

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `disabled` | `boolean` | Current disable state |

[DatePickerPrev.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerPrev.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |

### Next Button

Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `nextPage` |  | `((placeholder: DateValue) => DateValue)` | The function to be used for the next page. Overwrites the `nextPage` function set on the `CalendarRoot`. |

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `disabled` | `boolean` | Current disable state |

[DatePickerNext.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerNext.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |

### Heading

Heading for displaying the current month and year/

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `headingValue` | `string` | Current month and year |

[DatePickerHeading.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerHeading.vue)

### Grid

Container for wrapping the calendar grid.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerGrid.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerGrid.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |
| `[data-readonly]` | Present when readonly |

### Grid Head

Container for wrapping the grid head.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerGridHead.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerGridHead.vue)

### Grid Body

Container for wrapping the grid body.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerGridBody.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerGridBody.vue)

### Grid Row

Container for wrapping the grid row.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerGridRow.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerGridRow.vue)

### Head Cell

Container for wrapping the head cell. Used for displaying the week days.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |

[DatePickerHeadCell.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerHeadCell.vue)

### Cell

Container for wrapping the calendar cells.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `date*` |  | `DateValue` | The date value for the cell |

[DatePickerCell.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerCell.vue)

| Data attribute | Value |
| --- | --- |
| `[data-disabled]` | Present when disabled |

### Cell Trigger

Interactable container for displaying the cell dates. Clicking it selects the date.

**Props**

| Prop | Default | Type | Description |
| --- | --- | --- | --- |
| `as` | `"div"` | `AsTag \| Component` | The element or component this component should render as. Can be overwritten by `asChild`. |
| `asChild` |  | `boolean` | Change the default rendered element for the one passed as a child, merging their props and behavior.<br><br>Read our [Composition](/akar/guides/composition) guide for more details. |
| `day*` |  | `DateValue` | The date value provided to the cell trigger |
| `month*` |  | `DateValue` | The month in which the cell is rendered |

**Slots**

| Slot | Payload | Description |
| --- | --- | --- |
| `dayValue` | `string` | Current day |
| `disabled` | `boolean` | Current disable state |
| `selected` | `boolean` | Current selected state |
| `today` | `boolean` | Current today state |
| `outsideView` | `boolean` | Current outside view state |
| `outsideVisibleView` | `boolean` | Current outside visible view state |
| `unavailable` | `boolean` | Current unavailable state |

[DatePickerCellTrigger.vue source](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker/DatePickerCellTrigger.vue)

| Data attribute | Value |
| --- | --- |
| `[data-selected]` | Present when selected |
| `[data-value]` | The ISO string value of the date. |
| `[data-disabled]` | Present when disabled |
| `[data-unavailable]` | Present when unavailable |
| `[data-today]` | Present when today |
| `[data-outside-view]` | Present when the date is outside the current month it is displayed in. |
| `[data-outside-visible-view]` | Present when the date is outside the months that are visible on the calendar. |
| `[data-focused]` | Present when focused |

## Accessibility

### Keyboard Interactions

| Key | Description |
| --- | --- |
| <kbd>Tab</kbd> | When focus moves onto the date field, focuses the first segment. |
| <kbd>Space</kbd> |  When the focus is on either `DatePickerNext` or `DatePickerPrev`, it navigates the calendar. Otherwise, it selects the date. If the focus is on `DatePickerTrigger`, it opens/closes the popover.  |
| <kbd>Enter</kbd> |  When the focus is on either `DatePickerNext` or `DatePickerPrev`, it navigates the calendar. Otherwise, it selects the date. If the focus is on `DatePickerTrigger`, it opens/closes the popover.  |
| <kbd>ArrowLeft</kbd> / <kbd>ArrowRight</kbd> | Navigates between the date field segments. If the focus is on the `DatePickerCalendar`, it navigates between the dates. |
| <kbd>ArrowUp</kbd> / <kbd>ArrowDown</kbd> | Increments/changes the value of the segment. If the focus is on the `DatePickerCalendar`, it navigates between the dates. |
| <kbd>0-9</kbd> | When the focus is on a numeric `DatePickerInput`, it types in the number and focuses the next segment if the next input would result in an invalid value. |
| <kbd>Backspace</kbd> | Deletes a digit from the focused numeric segments. |
| <kbd>A</kbd> / <kbd>P</kbd> | When the focus is on the day period, it sets it to AM or PM. |

---

- [GitHub](https://github.com/vinicunca/akar/blob/v2.0.20/packages/core/src/DatePicker)
- [npm](https://www.npmjs.com/package/akar)


## Sitemap

See the full [sitemap](https://vinicunca.dev/sitemap.md) for all pages.
