Calendar
A month grid on react-day-picker with Keyline chevrons.
A month to place in a card or a popover, for one date, several dates or a range. For a date field with its own popover, use @khaeli/date-picker. Pass a locale from react-day-picker/locale: it sets the language of the names, the first day of the week and the format of each day's data-day, the same on the server and in the browser.
One date
"use client"
import { useState } from "react"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarOneDate() {
const [due, setDue] = useState<Date | undefined>(new Date(2026, 2, 12))
return (
<Calendar
mode="single"
locale={enGB}
defaultMonth={new Date(2026, 2)}
selected={due}
onSelect={setDue}
labels={{ labelNav: () => "Due date months" }}
/>
)
}
Date range
"use client"
import { useState } from "react"
import type { DateRange } from "react-day-picker"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarDateRange() {
const [sprint, setSprint] = useState<DateRange | undefined>({
from: new Date(2026, 2, 9),
to: new Date(2026, 2, 20),
})
return (
<Calendar
mode="range"
locale={enGB}
defaultMonth={new Date(2026, 2)}
selected={sprint}
onSelect={setSprint}
labels={{ labelNav: () => "Sprint months" }}
/>
)
}
Two months
"use client"
import { useState } from "react"
import type { DateRange } from "react-day-picker"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarTwoMonths() {
const [freeze, setFreeze] = useState<DateRange | undefined>({
from: new Date(2026, 2, 23),
to: new Date(2026, 3, 8),
})
return (
<Calendar
mode="range"
locale={enGB}
numberOfMonths={2}
defaultMonth={new Date(2026, 2)}
selected={freeze}
onSelect={setFreeze}
labels={{ labelNav: () => "Release freeze months" }}
/>
)
}
Month and year menus
"use client"
import { useState } from "react"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarMonthAndYearMenus() {
const [issued, setIssued] = useState<Date | undefined>(new Date(2026, 2, 12))
return (
<Calendar
mode="single"
locale={enGB}
captionLayout="dropdown"
startMonth={new Date(2024, 0)}
endMonth={new Date(2027, 11)}
defaultMonth={new Date(2026, 2)}
selected={issued}
onSelect={setIssued}
labels={{ labelNav: () => "Issue date months" }}
/>
)
}
Days that cannot be picked
"use client"
import { useState } from "react"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarDaysThatCannotBePicked() {
const [payment, setPayment] = useState<Date | undefined>(new Date(2026, 2, 18))
return (
<Calendar
mode="single"
locale={enGB}
defaultMonth={new Date(2026, 2)}
selected={payment}
onSelect={setPayment}
disabled={[{ before: new Date(2026, 2, 9) }, { dayOfWeek: [0, 6] }]}
labels={{ labelNav: () => "Payment date months" }}
/>
)
}
Week numbers
"use client"
import { useState } from "react"
import { enGB } from "react-day-picker/locale"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarWeekNumbers() {
const [review, setReview] = useState<Date | undefined>(new Date(2026, 2, 12))
return (
<Calendar
mode="single"
locale={enGB}
showWeekNumber
defaultMonth={new Date(2026, 2)}
selected={review}
onSelect={setReview}
labels={{ labelNav: () => "Review date months" }}
/>
)
}
Installation
npx shadcn@latest add @khaeli/calendarbunx --bun shadcn@latest add @khaeli/calendarInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
- npm packages
- @keyline-icons/react ^2.2.0
- react-day-picker ^10.0.1
Keyboard
Tab- Moves to the previous-month and next-month buttons, then into the days. One day is in the tab order: the chosen day, else today, else the first of the month.
ArrowLeftArrowRight- Move focus to the day before and the day after. Days that cannot be picked are skipped.
ArrowUpArrowDown- Move focus to the same weekday in the week before and the week after.
HomeEnd- Move focus to the start and to the end of the week.
PageUpPageDown- Move focus to the same day in the month before and the month after.
Shift + PageUpShift + PageDown- Move focus to the same day in the year before and the year after.
EnterSpace- Choose the focused day. Focus stays on it.
Accessible name
- The grid is named by the month it shows, such as "March 2026".
- Each day is a button named in full, such as "Thursday, 12 March 2026", with "Today" and "selected" added where they apply.
- The month buttons are named "Go to the Previous Month" and "Go to the Next Month". With
captionLayout="dropdown"the menus are named "Choose the Month" and "Choose the Year". - The month buttons sit in a
navlandmark named "Navigation bar". Where a page shows more than one calendar, name each one for its date:labels={{ labelNav: () => "Due date months" }}. - Selection is not conveyed by colour alone: the chosen day's name says "selected". A day that cannot be picked is a disabled button.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/calendar.json