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

    768
  • Calendar with time pressets

    Calendar with time pressets

    503
  • Sidebar

    Sidebar

    339
  • Sonner

    Sonner

    229
  • Chart

    Chart

    212
  • Icons

    Icons

    176
  • Dropdown Menu

    Dropdown Menu

    148
  • Calendar with event slots

    Calendar with event slots

    115

More in Forms

View all
  • Premium Auth

    Premium Auth

    494
  • Login 1

    Login 1

    52
  • Authentication Card

    Authentication Card

    44
  • Login 2

    Login 2

    7
  • Form

    Form

    31
  • Login Card

    Login Card

    32
  • Card Studio

    Card Studio

    41
  • Form

    Form

    136