Component guideEditable source

Calendar

A day-picker surface for selecting a single date, multiple dates, or a range.

Original component docs
On this page6 sectionsBack to top

Use Calendar for visible date selection. Use Date Picker to put it in a popover. It wraps React DayPicker; the selection mode determines the types of selected and onSelect.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/calendar.json

For range selection, use DateRange | undefined from react-day-picker. Install date-fns separately when copying a recipe that imports it.

npm install date-fns

#Usage

"use client";
import { useState } from "react";
import { Calendar } from "@/components/ui/calendar";

export default function ChooseDate() {
  const [date, setDate] = useState<Date | undefined>();
  return (
    <div className="grid gap-3">
      <Calendar mode="single" selected={date} onSelect={setDate} aria-label="Appointment date" />
      <p role="status">{date ? date.toDateString() : "No date selected"}</p>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
modesingle, multiple, or rangeNo selection mode
selected / onSelectControlled date, dates, or range—
month / onMonthChangeControlled displayed monthCurrent month if uncontrolled
defaultMonthInitial displayed monthCurrent month
disabledDates that cannot be selectedUnrestricted
startMonth / endMonthNavigation boundsUnrestricted
showOutsideDaysShow adjacent-month daystrue
captionLayout / numberOfMonthsMonth controls and visible month countlabel / 1
locale / formattersNative DayPicker date labels and formattingDayPicker defaults (en-US)
buttonVariantMonth navigation appearance: default, outline, ghost, destructive, link, noShadow, neutral, or reverseghost

Month labels use DayPicker's DateLib and its locale, rather than the browser's language. Pass a DayPicker locale or native formatter when you need a different language. Day buttons use DayPicker's stable yyyy-MM-dd date identifier for data-day.

#Accessibility

Label the surrounding field or region. Arrow keys navigate dates. Include a textual selected-date summary when the selection matters. Disabled dates differ from navigation bounds. Treat date-only values separately from timestamps when storing or sending them; converting local midnight to UTC can change the calendar date.

#Examples

#Range

Loading preview...