shadcn

Calendar picker in a drawer

Forms 22

About

Here is Shadcn Calendar picker in a drawer

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Calendar picker in a drawer to your project and fits it to your theme.

Code

How Calendar picker in a drawer is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import * as React from "react"
import { CalendarDate, getLocalTimeZone } from "@internationalized/date"
import { CalendarPlusIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

import { Calendar } from "@/components/ui/calendar-rac"
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
import { Label } from "@/components/ui/label"

export function Calendar32() {
  const [open, setOpen] = React.useState(false)
  const [date, setDate] = React.useState<CalendarDate | null>(null)

  return (
    <div className="flex flex-col gap-3">
      <Label htmlFor="date" className="px-1">
        Date of birth
      </Label>
      <Drawer open={open} onOpenChange={setOpen}>
        <DrawerTrigger asChild>
          <Button
            variant="outline"
            id="date"
            className="w-48 justify-between font-normal"
          >
            {date
              ? date.toDate(getLocalTimeZone()).toLocaleDateString("ru-RU")
              : "Выберите дату"}
            <CalendarPlusIcon />
          </Button>
        </DrawerTrigger>
        <DrawerContent className="w-auto overflow-hidden p-0">
          <DrawerHeader className="sr-only">
            <DrawerTitle>Select date</DrawerTitle>
            <DrawerDescription>Set your date of birth</DrawerDescription>
          </DrawerHeader>
          <Calendar
            aria-label="Date of birth" 
            value={date}
            onChange={(newDate) => {
              setDate(newDate)
              setOpen(false)
            }}
            className="mx-auto [--cell-size:clamp(0px,calc(100vw/7.5),52px)]"
          />
        </DrawerContent>
      </Drawer>
      <div className="text-muted-foreground px-1 text-sm">
        This example works best on mobile.
      </div>
    </div>
  )
}

More by shadcn

View all
  • Navigation menu

    Navigation menu

    777
  • Calendar with time pressets

    Calendar with time pressets

    507
  • Sidebar

    Sidebar

    344
  • Sonner

    Sonner

    235
  • Chart

    Chart

    220
  • Icons

    Icons

    186
  • Dropdown Menu

    Dropdown Menu

    151
  • Calendar with event slots

    Calendar with event slots

    117

More in Forms

View all
  • Premium Auth

    Premium Auth

    518
  • Contact Card

    Contact Card

    1K
  • Book A Demo 1

    Book A Demo 1

    72
  • Login 1

    Login 1

    52
  • Authentication Card

    Authentication Card

    48
  • Login Card

    Login Card

    6
  • Form

    Form

    16
  • Modern & Stunning sign in

    Modern & Stunning sign in

    1.6K