---
title: DatePicker
description: "`DatePicker` is a component used for users to select a date."
links:
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/date-picker
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-datepicker--basic
---
```tsx
```
## Usage
```tsx
import { DatePicker } from "@yamada-ui/react"
```
```tsx
import { DatePicker } from "@/components/ui"
```
```tsx
import { DatePicker } from "@workspaces/ui"
```
```tsx
```
### Change Variant
```tsx
{(variant, index) => (
)}
```
### Change Size
```tsx preview
{(size, index) => (
)}
```
### Change Color Scheme
```tsx
{(colorScheme, index) => (
)}
```
### Change Format
To change the format, set the `format` object.
```tsx
const format = useMemo(
() => ({
input: null,
month: "long",
weekday: "narrow",
year: "2-digit",
}),
[],
)
return
```
### Set Default Date
To set a default date, set `defaultValue` to a `Date`.
```tsx
```
### Set Default Input Value
To set a default input value, specify a string for `defaultInputValue`.
```tsx
```
### Set Default Month
To set a default month, set `defaultMonth` to a `Date`.
```tsx
```
### Set Minimum Date
To set the minimum selectable date, set `minDate` to a `Date`.
```tsx
```
### Set Maximum Date
To set the maximum selectable date, set `maxDate` to a `Date`.
```tsx
```
### Allow Values Outside Minimum and Maximum Range
By default, if a date outside the minimum and maximum range is entered, it is automatically replaced with the minimum or maximum date. To disable this control and allow values outside the range, set `allowInputBeyond` to `true`.
```tsx
```
### Disable Today Highlighting
To disable highlighting of today's date, set `today` to `false`.
```tsx
```
### Disable Specific Days of the Week
To disable specific days of the week, set `excludeDate` to a condition function.
```tsx
[0, 1, 6].includes(date.getDay())} />
```
### Enable Multiple Selection
To enable multiple date selection, set `multiple` to `true`.
```tsx
```
### Set Maximum for Multiple Selection
To set the maximum number of selectable dates in multiple selection, set `max` to a number.
```tsx
```
### Change Separator
To change the separator, specify a string for `separator`. By default, `,` is set.
```tsx
```
### Enable Range Selection
To enable range selection, set `range` to `true`.
```tsx
```
### Change Start Day of Week
To change the start day of the week, set `startDayOfWeek` to `"sunday"` or `"monday"`.
```tsx
```
### Change Weekend Days
To change which days are treated as weekends, set `weekendDays` to an array of days(numbers).
```tsx
```
### Set Pattern
To set a pattern, set a regular expression to `pattern`.
```tsx
```
### Handle Parsing of Entered Values
To handle the parsing of entered values, use `parseDate`.
```tsx
new Date(value)} />
```
### Set Holidays
To set holidays, set `holidays` to an array of `Date`s.
```tsx
const holidays = useMemo(
() => [
new Date("2025-01-01"),
new Date("2025-01-13"),
new Date("2025-02-11"),
new Date("2025-02-23"),
new Date("2025-02-24"),
new Date("2025-03-20"),
new Date("2025-04-29"),
new Date("2025-05-03"),
new Date("2025-05-04"),
new Date("2025-05-05"),
new Date("2025-05-06"),
new Date("2025-07-21"),
new Date("2025-08-11"),
new Date("2025-09-15"),
new Date("2025-09-23"),
new Date("2025-10-13"),
new Date("2025-11-03"),
new Date("2025-11-23"),
new Date("2025-11-24"),
new Date("2026-01-01"),
new Date("2026-01-12"),
new Date("2026-02-11"),
new Date("2026-02-23"),
new Date("2026-03-20"),
new Date("2026-04-29"),
new Date("2026-05-03"),
new Date("2026-05-04"),
new Date("2026-05-05"),
new Date("2026-05-06"),
new Date("2026-07-20"),
new Date("2026-08-11"),
new Date("2026-09-21"),
new Date("2026-09-22"),
new Date("2026-10-12"),
new Date("2026-11-03"),
new Date("2026-11-23"),
],
[],
)
return
```
### Hide Outside the Current Month
To hide dates outside the current month, set styles using `dayProps`.
```tsx
```
### Change Offset
To change the offset, specify a value for `gutter` or `offset`.
```tsx
```
### Change Animation
To change the animation, specify `"block-start"` or `"inline-end"` for `animationScheme`. By default, `"scale"` is set.
```tsx
```
### Change Placement
To change the placement, specify `"end"` or `"start-center"` for `placement`. By default, `"end-start"` is set.
```tsx
```
### Blocking Scroll
To block scrolling, set `blockScrollOnMount` to `true`.
```tsx
```
### Close Dropdown On Scroll
To close the dropdown on scroll, set `closeOnScroll` to `true`.
```tsx
```
### Handle opening the dropdown on change
To handle the event of opening the dropdown on change, set a function to `openOnChange`.
```tsx
ev.target.value.length > 1}
/>
```
### Handle closing the dropdown on change
To handle the event of closing the dropdown on change, set a function to `closeOnChange`.
```tsx
!ev.target.value.length}
/>
```
### Disable Open Dropdown On Focus
To disable opening the dropdown on focus, set `openOnFocus` to `false`.
```tsx
```
### Disable Open Dropdown On Click
To disable opening the dropdown on click, set `openOnClick` to `false`.
```tsx
```
### Disable Focus After Clear
To disable focus after clear, set `focusOnClear` to `false`.
```tsx
```
### Disable Close On Select
To disable closing the dropdown on select, set `closeOnSelect` to `false`.
```tsx
```
### Disable Close On Outside Click
To disable closing dropdown when clicking outside, set `closeOnBlur` to `false`.
```tsx
```
### Disable Close On Esc
To disable closing the dropdown with the Esc key, set `closeOnEsc` to `false`.
```tsx
```
### Disable Clear Button
To disable the clear button, set `clearable` to `false`.
```tsx
```
### Disallow Input
To disallow input, set `allowInput` to `false`.
```tsx
```
### Change Shape
```tsx
{(shape, index) => (
)}
```
### Disable
To disable, set `disabled` to `true`.
```tsx
{(variant, index) => (
)}
```
### Read-Only
To make read-only, set `readOnly` to `true`.
```tsx
{(variant, index) => (
)}
```
### Invalid
To make invalid, set `invalid` to `true`.
```tsx
{(variant, index) => (
)}
```
### Change Border Color
To customize focus and error border colors, set colors for `focusBorderColor` or `errorBorderColor`.
```tsx
```
### Customize Icon
```tsx
} />
```
### Customize Multiple Selection Display
```tsx
(
{value}
)}
/>
```
### Customize Calendar
You can customize Calendar to change the display.
```tsx preview client
{({ month }) =>
`${month.getFullYear()}/${(month.getMonth() + 1).toString().padStart(2, "0")}`
}
(
{value.getDate()}
),
}}
/>
```
### Control
```tsx
const [value, onChange] = useState(new Date())
return
```
## Props
| Prop | Default | Type | Description |
| ---------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | `"outline"` | `"filled" \| "flushed" \| "outline" \| "plain"` | The variant of the component. |
| `allowInput` | `true` | `boolean` | If `true`, allows input. |
| `allowInputBeyond` | `true` | `boolean` | If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions. |
| `animationScheme` | `"scale"` | `"none" \| "scale" \| SimplePlacement` | The animation of the element. |
| `autoUpdate` | `true` | `boolean` | If `true`, automatically updates the position of the floating element when necessary. |
| `blockScrollOnMount` | `false` | `boolean` | If `true`, scrolling will be disabled on the `body` when the modal opens. |
| `calendarProps` | - | `Calendar.RootProps` | The size of the calendar component. |
| `clearable` | `true` | `boolean` | If `true`, display the clear icon. |
| `clearIcon` | - | `ReactNode` | The icon to be used in the clear button. |
| `closeOnBlur` | `true` | `boolean` | If `true`, the popover will close when you blur out it by clicking outside or tabbing out. |
| `closeOnChange` | `false` | `((ev: ChangeEvent) => boolean) \| boolean` | If `true`, the date picker will be closed when the input value changes. |
| `closeOnEsc` | `true` | `boolean` | If `true`, the popover will hide on pressing Esc key. |
| `closeOnScroll` | `false` | `boolean` | If `true`, the popover will hide on scroll. |
| `closeOnSelect` | `true` | `boolean` | If `true`, the list element will be closed when value is selected. |
| `contentProps` | - | `DatePickerContentProps` | Props for content element. |
| `defaultInputValue` | - | `MaybeInputValue` | The initial value of the input. |
| `defaultMonth` | `new Date()` | `Date` | The initial month of the calendar. |
| `defaultOpen` | - | `boolean` | If `true`, the element will be initially opened. |
| `defaultValue` | - | `NonNullable>` | The initial value of the calendar. |
| `disabled` | `false` | `boolean` | If `true`, disables the calendar. |
| `duration` | `0.2` | `MotionTransitionProps["duration"]` | The animation duration. |
| `elementProps` | - | `InputGroup.ElementProps` | The props for the end element. |
| `elements` | - | `{ floating?: HTMLElement \| null \| undefined; reference?: HTMLButtonElement \| null \| undefined }` | Object containing the reference and floating elements. |
| `errorBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is invalid. |
| `excludeDate` | - | `(date: Date) => boolean` | Callback function to determine whether the day should be disabled. |
| `flip` | `true` | `boolean` | If `true`, the popper will change its placement and flip when it's about to overflow its boundary area. |
| `focusBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is focused. |
| `focusOnClear` | `true` | `boolean` | If `true`, the input will be focused when the clear icon is clicked. |
| `format` | - | `DatePickerFormat` | The format used for conversion. Check the docs to see the format of possible modifiers you can pass. |
| `gutter` | `8` | `number` | The distance or margin between the reference and popper. It is used internally to create an `offset` modifier. |
| `holidays` | - | `Date[]` | Define holidays. |
| `icon` | - | `ReactNode` | The icon to be used in the date picker. |
| `iconProps` | - | `DatePickerIconProps` | Props for icon element. |
| `inputProps` | - | `HTMLStyledProps<"input">` | The props for the input element. |
| `inputValue` | - | `MaybeInputValue` | The value of the input. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `locale` | `"en-US"` | `AnyString \| "ar-AE" \| "bg-BG" \| "cs-CZ" \| "da-DK" \| "de-DE" \| "el-GR" \| "en-GB" \| "en-US" \| "es-ES" \| "et-EE" \| "fi-FI" \| "fr-CA" \| "fr-FR" \| "he-IL" \| "hr-HR" \| "hu-HU" \| ... 18 more ... \| "zh-TW"` | The locale of the calendar. |
| `matchWidth` | `false` | `boolean` | If `true`, the popper will match the width of the reference at all times. It's useful for `autocomplete`, `date-picker` and `select` patterns. |
| `max` | - | `number` | The maximum selectable value. |
| `maxDate` | `new Date(2099, 11, 31)` | `Date` | The maximum possible date. |
| `middleware` | - | `(false \| { name: string; options?: any; fn: (state: { x: number; y: number; placement: Placement; platform: Platform; strategy: Strategy; initialPlacement: Placement; middlewareData: MiddlewareData; rects: ElementRects; elements: Elements; }) => Promisable<...>; } \| null \| undefined)[]` | Array of middleware objects to modify the positioning or provide data for rendering. |
| `minDate` | `new Date(1900, 0, 1)` | `Date` | The minimum possible date. |
| `month` | - | `Date` | The month of the calendar. |
| `multiple` | `false` | `Multiple` | If `true`, the calendar will be multiple. |
| `name` | - | `string` | The `name` attribute of the input element. |
| `offset` | - | `[number, number]` | The main and cross-axis offset to displace popper element from its reference element. |
| `onChange` | - | `(value: MaybeDateValue) => void` | The callback invoked when value state changes. |
| `onChangeMonth` | - | `(value: Date) => void` | The callback invoked when month state changes. |
| `onClose` | - | `() => void \| Promise` | Callback invoked to close the element. |
| `onInputChange` | - | `(value: MaybeInputValue) => void` | The callback invoked when input value state changes. |
| `onOpen` | - | `() => void \| Promise` | Callback invoked to open the element. |
| `open` | - | `boolean` | If `true`, the element will be opened. |
| `openOnChange` | `true` | `((ev: ChangeEvent) => boolean) \| boolean` | If `true`, the date picker will be opened when the input value changes. |
| `openOnClick` | `true` | `boolean` | If `true`, the combobox will be opened when click on the field. |
| `openOnEnter` | `true` | `boolean` | If `true`, the combobox will be opened when enter is pressed. |
| `openOnFocus` | `true` | `boolean` | If `true`, the date picker will be opened when the input is focused. |
| `openOnSpace` | `true` | `boolean` | If `true`, the combobox will be opened when space is pressed. |
| `parseDate` | - | `(value: string) => Date \| undefined` | Function that converts the input value to Date type. |
| `pattern` | - | `RegExp` | The pattern used to check the input element. |
| `placeholder` | - | `string` | The placeholder for date picker. |
| `placement` | `"end-start"` | `Direction` | The placement of the popper relative to its reference. |
| `platform` | - | `Platform` | Custom or extended platform object. |
| `preventOverflow` | `true` | `boolean` | If `true`, will prevent the popper from being cut off and ensure it's visible within the boundary area. |
| `range` | `false` | `Range` | If `true`, enables date range selection. |
| `readOnly` | `false` | `boolean` | If `true`, the combobox will be readonly. |
| `render` | - | `(props: DatePickerRenderProps) => ReactNode` | The function to render the selected date. |
| `required` | `false` | `boolean` | If `true`, the field will be required. |
| `rootProps` | - | `InputGroup.RootProps` | Props for root element. |
| `selectFocusRef` | - | `RefObject` | The `ref` of the element that should receive focus when selected. |
| `selectOnSpace` | `true` | `boolean` | If `true`, the item will be selected when space is pressed. |
| `separator` | `","` | `string` | The visual separator between each value. |
| `startDayOfWeek` | `"monday"` | `StartDayOfWeek` | Define the start day of the week. |
| `strategy` | `"absolute"` | `Strategy` | The CSS positioning strategy to use. |
| `today` | `true` | `boolean` | If `true`, highlight today. |
| `transferFocus` | `true` | `boolean` | If `true`, the focus will be transferred to the popover content when the tab key is pressed. |
| `value` | - | `NonNullable>` | The value of the calendar. |
| `weekendDays` | `[0, 6]` | `number[]` | Define weekend days. |
| `whileElementsMounted` | - | `(reference: HTMLButtonElement, floating: HTMLElement, update: () => void) => () => void` | A callback invoked when both the reference and floating elements are mounted, and cleaned up when either is unmounted. This is useful for setting up event listeners (e.g. pass `autoUpdate`). |
## Accessibility
Currently, this section is being updated due to the migration of v2.