# Calendar

A month on graph paper to pick from: one day, several, or a range. Today is ringed, the chosen day shaded in with the pen, a range hatched between its ends.

Docs: https://ballpoint.st9wd.com/docs/calendar

```bash
npx shadcn@latest add @ballpoint/calendar
```

```tsx
import { Calendar } from "@/components/ui/calendar"

const [date, setDate] = useState<Date | undefined>(new Date())

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

Props:

- `mode`: `"single" | "multiple" | "range"` (default `"single"`). One day, many, or a start and an end. `selected` and `onSelect` take a Date, a Date[], or { from, to } to match.
- `selected / defaultSelected / onSelect`: `Date | Date[] | DateRange`. The selection, controlled or not. Clicking the chosen day again clears a single selection.
- `numberOfMonths`: `number` (default `1`). Months shown side by side.
- `month / defaultMonth / onMonthChange`: `Date`. Which month is showing.
- `startMonth / endMonth`: `Date`. The first and last month it can be taken to.
- `disabled`: `boolean | (date) => boolean | Date | { before, after, from, to, dayOfWeek } | list`. Days that can't be picked.
- `weekStartsOn`: `0 | 1 | 2 | 3 | 4 | 5 | 6` (default `0`). The first day of the week; 0 is Sunday.
- `showOutsideDays`: `boolean` (default `true`). Show the days of neighbouring months that share a row.
- `captionLayout`: `"label" | "dropdown"` (default `"label"`). The month and year in words, or two dropdowns to pick them.
- `locale`: `string` (default `"en-US"`). A BCP 47 tag for the names of months and days.
- `seed`: `string | number`. Pins the drawing.

Pen settings: `draw`, `roughness`, `weight`, `speed` (see Pen settings).

## Example

```tsx
"use client";

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

export default function CalendarDemo() {
  const [date, setDate] = useState<Date | undefined>(new Date(2026, 9, 17));
  return <Calendar mode="single" selected={date} onSelect={setDate} defaultMonth={new Date(2026, 9, 1)} seed="cal-demo" />;
}
```

## Range

Two months side by side, with the days between the ends hatched.

```tsx
"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(2026, 9, 8), to: new Date(2026, 9, 15) });
  return <Calendar mode="range" numberOfMonths={2} selected={range} onSelect={setRange} defaultMonth={new Date(2026, 9, 1)} seed="cal-range" />;
}
```

## Multiple days

Each click adds a day or takes it away.

```tsx
"use client";

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

export default function CalendarMultiple() {
  const [days, setDays] = useState<Date[] | undefined>([new Date(2026, 9, 5), new Date(2026, 9, 12), new Date(2026, 9, 19)]);
  return (
    <div className="flex flex-col items-start gap-2">
      <Calendar mode="multiple" selected={days} onSelect={setDays} defaultMonth={new Date(2026, 9, 1)} seed="cal-multi" />
      <p className="px-3 text-ink-2" aria-live="polite">
        {days?.length ? `${days.length} day${days.length === 1 ? "" : "s"} picked.` : "Pick the days you can make."}
      </p>
    </div>
  );
}
```

## Disabled days

No weekends and nothing before the 5th; weeks start on Monday and days from other months are left out.

```tsx
"use client";

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

export default function CalendarDisabled() {
  const [date, setDate] = useState<Date | undefined>();
  return (
    <Calendar
      mode="single"
      selected={date}
      onSelect={setDate}
      defaultMonth={new Date(2026, 9, 1)}
      weekStartsOn={1}
      showOutsideDays={false}
      // No weekends, and nothing before the 5th.
      disabled={[{ dayOfWeek: [0, 6] }, { before: new Date(2026, 9, 5) }]}
      seed="cal-disabled"
    />
  );
}
```

## Month and year dropdowns

For dates far from today, such as a date of birth.

```tsx
"use client";

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

export default function CalendarDropdown() {
  const [date, setDate] = useState<Date | undefined>(new Date(1994, 4, 21));
  return <Calendar mode="single" selected={date} onSelect={setDate} captionLayout="dropdown" startMonth={new Date(1940, 0)} endMonth={new Date(2026, 11)} seed="cal-drop" />;
}
```

## Another language

Names of months and days come from Intl, so any locale works.

```tsx
"use client";

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

export default function CalendarLocale() {
  const [date, setDate] = useState<Date | undefined>(new Date(2026, 9, 17));
  return <Calendar mode="single" selected={date} onSelect={setDate} defaultMonth={new Date(2026, 9, 1)} locale="fr-FR" weekStartsOn={1} seed="cal-fr" />;
}
```

## Pen settings

- `draw`: `"auto" | "mount" | "none"` (default `"auto"`). When the strokes draw themselves in: the first time they scroll into view, as soon as they render, or never (already drawn).
- `roughness`: `number` (default `1`). 0 is ruler-neat, 1 a quick confident hand, 2 a scrawl.
- `weight`: `number` (default `1`). Line weight multiplier. Also settable in CSS as --ink-weight.
- `speed`: `number` (default `1`). Drawing speed multiplier. Also settable in CSS as --ink-speed.
