Calendar

A month grid for picking a date, several dates or a range.

June 2025
"use client"

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

export default function CalendarDemo() {
  const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 12))
  return <Calendar mode="single" defaultMonth={date} selected={date} onSelect={setDate} />
}

Installation

pnpm dlx shadcn@latest add @arene/calendar

Needs the arene setup first. Also adds Button and Select.

Usage

import { Calendar } from "@/components/ui/calendar"
const [date, setDate] = useState<Date | undefined>(new Date())

return <Calendar mode="single" selected={date} onSelect={setDate} />

Calendar is React DayPicker with arene's styles on every part. Selection, keyboard navigation, locales and disabled-date matchers all come from DayPicker, and every DayPicker prop works.

Range

mode="range" selects a start and an end. The days between them sit on a continuous band, and numberOfMonths lays months side by side from the md breakpoint, stacked below it.

June 2025
July 2025
"use client"

import { useState } from "react"
import { Calendar, type DateRange } from "@/components/ui/calendar"

export default function CalendarRange() {
  const [range, setRange] = useState<DateRange | undefined>({
    from: new Date(2025, 5, 12),
    to: new Date(2025, 6, 4),
  })
  return (
    <Calendar
      mode="range"
      numberOfMonths={2}
      defaultMonth={range?.from}
      selected={range}
      onSelect={setRange}
    />
  )
}

Multiple

mode="multiple" toggles each day it is given.

June 2025
"use client"

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

export default function CalendarMultiple() {
  const [dates, setDates] = useState<Date[] | undefined>([
    new Date(2025, 5, 3),
    new Date(2025, 5, 12),
    new Date(2025, 5, 13),
    new Date(2025, 5, 24),
  ])
  return (
    <Calendar
      mode="multiple"
      defaultMonth={new Date(2025, 5)}
      selected={dates}
      onSelect={setDates}
    />
  )
}

Month and year dropdowns

captionLayout="dropdown" swaps the caption for a month and a year dropdown. startMonth and endMonth bound the years they list. They are native select elements, so a phone opens its own wheel picker.

June 2025
"use client"

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

export default function CalendarDropdown() {
  const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 12))
  return (
    <Calendar
      mode="single"
      captionLayout="dropdown"
      startMonth={new Date(1950, 0)}
      endMonth={new Date(2030, 11)}
      defaultMonth={date}
      selected={date}
      onSelect={setDate}
    />
  )
}

Disabled days

disabled takes a date, an array of dates or a matcher. This one rules out weekends and every day before the 9th.

June 2025
"use client"

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

export default function CalendarDisabled() {
  const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 12))
  return (
    <Calendar
      mode="single"
      defaultMonth={date}
      selected={date}
      onSelect={setDate}
      disabled={[{ before: new Date(2025, 5, 9) }, { dayOfWeek: [0, 6] }]}
    />
  )
}

Week numbers

showWeekNumber adds a column of ISO week numbers. weekStartsOn={1} starts the week on Monday to match them.

June 2025
22
23
24
25
26
27
"use client"

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

export default function CalendarWeekNumbers() {
  const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 12))
  return (
    <Calendar
      mode="single"
      showWeekNumber
      weekStartsOn={1}
      defaultMonth={date}
      selected={date}
      onSelect={setDate}
    />
  )
}

A calendar rendered on the server shows the server's month and today. Pass defaultMonth when the HTML is prerendered, or the page shows the month it was built in until the visitor changes it. A calendar inside a popover renders only in the browser, so it does not have this problem.

API reference

Calendar accepts every DayPicker prop except animate. It changes one default and adds xstyle.

PropTypeDefault
showOutsideDaysbooleantrue
xstyleStyleXStyles—
classNamestring—
styleCSSProperties—
classNamesPartial<ClassNames>—
componentsPartial<CustomComponents>—

classNames adds to arene's classes instead of replacing them, so a plain CSS hook can sit on any part. Every part keeps DayPicker's own rdp-* class too. components replaces a part outright. CalendarDayButton is exported so a custom DayButton can wrap it rather than rebuild the day states.

The month dropdown shows short month names. Pass formatters with your own formatMonthDropdown to change it.

Cell size

Every day, weekday and caption is --arene-calendar-cell-size square, 2rem by default. Set it through xstyle to resize the grid.

calendarStyles

The style maps behind the component: root, parts (keyed by DayPicker's part names), day, dayButton, outside, today, selected, disabled and range.

Data attributes

AttributeOnEffect
data-slot="calendar"the rootCalendar root
data-selected, data-today, data-outsidea day cellDayPicker writes the day's state
data-disabled, data-hidden, data-focuseda day cellDayPicker writes the day's state