Components

Calendar

A calendar component that allows users to select a date or a range of dates.

PreviewSource
October 2026

Installation

Complete the project setup first. The init command configures TypeScript, Vite, Tailwind CSS v4, and Preact compatibility.

CLI

Run init once using the installation guide, then add this component. The CLI copies the required source files and installs their exact dependencies with Bun.

bunx --bun github:LiasCode/shadcn-preact#main add calendar

Add --dry-run to review the changes. Existing modified files are protected; use --overwrite only when you want to replace them.

Manual installation / degit (optional)

1. Install dependencies

bun add --exact class-variance-authority@0.7.1 cn@0.4.0 lucide-preact@1.55.0 preact@11.0.1 react-day-picker@10.0.2 tw-animate-css@1.4.0

2. Copy the component with degit

Run this from your project root. It selects calendar.tsx, its local dependencies, and both licenses directly from the repository, then copies them into src/components/ui.

bunx degit@3.10.0 https://github.com/LiasCode/shadcn-preact#main ./.cache/shadcn-preact/calendar --files LICENSE.md,registry/ui/button.tsx,registry/ui/calendar.tsx,registry/ui/lib/utils.ts,registry/ui/primitives/LICENSE,registry/ui/primitives/button/Button.tsx,registry/ui/primitives/button/index.ts,registry/ui/primitives/internals/composite/root/CompositeRootContext.ts,registry/ui/primitives/internals/empty.ts,registry/ui/primitives/internals/getReactElementRef.ts,registry/ui/primitives/internals/getStateAttributesProps.ts,registry/ui/primitives/internals/mergeObjects.ts,registry/ui/primitives/internals/resolveClassName.ts,registry/ui/primitives/internals/resolveStyle.ts,registry/ui/primitives/internals/types.ts,registry/ui/primitives/internals/useButton.ts,registry/ui/primitives/internals/useFocusableWhenDisabled.ts,registry/ui/primitives/internals/useIsoLayoutEffect.ts,registry/ui/primitives/internals/useMergedRefs.ts,registry/ui/primitives/internals/useRefWithInit.ts,registry/ui/primitives/internals/useRenderElement.ts,registry/ui/primitives/internals/useStableCallback.ts,registry/ui/primitives/merge-props/index.ts --force
mkdir -p ./src/components/ui
cp -R ./.cache/shadcn-preact/calendar/registry/ui/. ./src/components/ui/
cp ./.cache/shadcn-preact/calendar/LICENSE.md ./src/components/ui/LICENSE.md

The temporary copy lives in .cache/shadcn-preact/calendar. Existing components stay in place; shared source files are updated from main.

Selected source files (22)

Usage

import * as React from "preact/compat";
import { Calendar } from "./components/ui/calendar"
const [date, setDate] = React.useState<Date | undefined>(new Date())

return (
  <Calendar
    mode="single"
    selected={date}
    onSelect={setDate}
    className="rounded-lg border"
  />
)

Examples

Basic

A basic calendar component. We used className="rounded-lg border" to style the calendar.

BasicSource
October 2026

Range Calendar

Use the mode="range" prop to enable range selection.

Range CalendarSource
January 2026
February 2026
Example requirements
bun add --exact date-fns@4.4.0 react-day-picker@10.0.2

Month and Year Selector

Use captionLayout="dropdown" to show month and year dropdowns.

Month and Year SelectorSource
October 2026

Presets

PresetsSource
October 2026
Example requirements

Also uses: Button, Card.

bun add --exact date-fns@4.4.0

Date and Time Picker

Date and Time PickerSource
October 2026
Example requirements

Also uses: Card, Field, Input Group.

bun add --exact lucide-preact@1.55.0

Booked dates

Booked datesSource
January 2026
Example requirements

Also uses: Card.

Custom Cell Size

Custom Cell SizeSource
December 2026
Example requirements

Also uses: Card.

bun add --exact date-fns@4.4.0 react-day-picker@10.0.2

Week Numbers

Use showWeekNumber to show week numbers.

Week NumbersSource
January 2026
01
02
03
04
05
Example requirements

Also uses: Card.

Multiple

MultipleSource
October 2026
Example requirements

Also uses: Card.

Reference

See the official Calendar documentation for composition patterns and API details. This page uses the Preact port and examples from the pinned upstream revision.

Component source