# Date Picker

A date picker component with range and presets.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).



<ComponentPreview name="date-picker-demo" />

## Installation [#installation]

The Date Picker is built using a composition of the `<Popover />` and the `<Calendar />` components.

See installation instructions for the [Popover](/docs/components/base/popover#installation) and the [Calendar](/docs/components/base/calendar#installation) components.

## Usage [#usage]

```tsx showLineNumbers title="components/example-date-picker.tsx"
"use client";

import * as React from "react";
import { format } from "date-fns";
import { Calendar as CalendarIcon } from "lucide-react";

import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/components/ui/popover";

export function DatePickerDemo() {
  const [date, setDate] = React.useState<Date>();

  return (
    <Popover>
      <PopoverTrigger
        render={
          <Button
            variant="outline"
            data-empty={!date}
            className="justify-start text-left font-normal data-[empty=true]:text-muted-foreground"
          />
        }
      >
        <CalendarIcon />
        {date ? format(date, "PPP") : <span>Pick a date</span>}
      </PopoverTrigger>
      <PopoverContent className="w-auto p-0">
        <Calendar mode="single" selected={date} onSelect={setDate} />
      </PopoverContent>
    </Popover>
  );
}
```

See the [React DayPicker](https://react-day-picker.js.org) documentation for more information.

## Composition [#composition]

A date picker is built from `Popover` and `Calendar` (there is no `DatePicker` root component):

```text
Popover
├── PopoverTrigger
└── PopoverContent
    └── Calendar
```

## Basic [#basic]

A basic date picker component.

<ComponentPreview name="date-picker-basic" />

## Range Picker [#range-picker]

A date picker component for selecting a range of dates.

<ComponentPreview name="date-picker-range" />

## Date of Birth [#date-of-birth]

A date picker component for selecting a date of birth. This component includes a dropdown caption layout for date and month selection.

<ComponentPreview name="date-picker-dob" />

## Input [#input]

A date picker component with an input field for selecting a date.

<ComponentPreview name="date-picker-input" />

## Time Picker [#time-picker]

A date picker component with a time input field for selecting a time.

<ComponentPreview name="date-picker-time" />

## Natural Language Picker [#natural-language-picker]

This component uses the `chrono-node` library to parse natural language dates.

<ComponentPreview name="date-picker-natural-language" />

## RTL [#rtl]

To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).

<ComponentPreview name="date-picker-rtl" direction="rtl" />
