Dokumentation (english)
Components: Shadcn UI

Calendar

Understand the design system and contribute to it

Component preview

The live preview for UI components is handled by components/atoms/codedocs/ComponentPreview.tsx. Use it directly inside MDX whenever you want a playground-style embed. Provide componentProps to set default values and propOptions to surface toggle-able props next to the preview.

Preview

Single date

January 2026

Date range

January 2026
February 2026

Prop reference

Auto-generated from the component source

Calendar

  • className
  • classNames
  • showOutsideDays = true
  • captionLayout = "label"
  • buttonVariant = "ghost"
  • formatters
  • components

React.ComponentProps<typeof DayPicker> & { buttonVariant?: React.ComponentProps<typeof Button>["variant"]; }

CalendarDayButton

  • className
  • day
  • modifiers

React.ComponentProps<typeof DayButton>

Code
// owner: Sona
"use client";

import * as React from "react";
import { addDays } from "date-fns";

import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";

export default function CalendarExample() {
  const [date, setDate] = React.useState<Date | undefined>(new Date());
  const [range, setRange] = React.useState<
    { from: Date; to: Date } | undefined
  >({
    from: new Date(),
    to: addDays(new Date(), 5),
  });

  return (
    <div className="flex flex-col gap-6 lg:flex-row">
      <div>
        <p className="text-sm font-medium mb-2">Single date</p>
        <Calendar
          mode="single"
          selected={date}
          onSelect={setDate}
          className="rounded-md border"
        />
        <Button
          variant="ghost"
          size="sm"
          className="mt-2"
          onClick={() => setDate(new Date())}
        >
          Today
        </Button>
      </div>
      <div>
        <p className="text-sm font-medium mb-2">Date range</p>
        <Calendar
          mode="range"
          selected={range}
          onSelect={(value) =>
            value && setRange(value as { from: Date; to: Date })
          }
          numberOfMonths={2}
          className="rounded-md border"
        />
      </div>
    </div>
  );
}

On this page


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items