组件

Calendar

A month on planner paper. The grid is ruled by hand, the day you chose is circled in marker, today is underlined in felt, a range is one highlighter swipe per week, and a day you may not pick is hatched out in pencil. react-day-picker v10 underneath: single, multiple and range selection, locales, right-to-left, week numbers, dropdown captions, several months.

安装

terminal
npx shadcn@latest add @wobko/calendar

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Planner page

One chosen day, circled in marker; today underlined; the days before the 3rd hatched out. On its own sheet of card, taped at the corner. (Fixed dates, so the page looks the same tomorrow.)

A range across two months

Pick a first and a last day and each week gets one highlighter swipe with chisel ends; week numbers go in the margin behind a red pencil rule.

Dropdowns and limits

Month and year are native selects in pencil boxes, so jumping to a birthday takes two taps. Weekends and the past are hatched out and cannot be chosen; the arrows stop at the ends of the range.

Book a call

A calendar on a card with time slots beside it: the chosen day drives the slots, the chosen slot drives the button. Weekends are closed, so they are hatched.

Other languages

Pass a react-day-picker locale: Spanish starts the week on Monday; Arabic runs right to left, with Eastern Arabic numerals and one-letter weekdays (a `formatWeekdayName`, since the short names of that language do not fit a cell), and the rules, arrows and swipe ends turn around with it.

API 参考

Calendar

A react-day-picker `DayPicker`, so every prop of DayPicker works (`mode`, `selected`, `onSelect`, `required`, `disabled`, `hidden`, `modifiers`, `locale`, `dir`, `numberOfMonths`, `startMonth` / `endMonth`, `showWeekNumber`, `weekStartsOn`, `footer`, `timeZone`, ...). The root is transparent so it sits on the paper it is placed on (Card, Popover, Page); `sheet` gives it a sheet of its own.

属性类型默认值说明
captionLayout"label" | "dropdown" | "dropdown-months" | "dropdown-years""label"The month name in script, or native month / year selects drawn in pencil boxes. Dropdowns default to a hundred years back (set `startMonth` / `endMonth`).
showOutsideDaysbooleantrueDays of the neighboring months in the first and last week, in graphite.
buttonVariantButtonProps['variant']"ghost"Variant of the previous / next month Buttons (real Buttons: hover swipe, press and drawn focus ring).
ruledbooleantrueHand-rule the grid (weekday rule, week rules, day rules, a red margin rule beside the week numbers). `false` leaves the page plain.
sheetboolean | PaperPropsfalsePut the calendar on a sheet of paper. `true` is a card; an object passes `stock`, `edge`, `tilt`, `tape`, `tapeKind`, `fastener`, `fastenerTone`, `fastenerClassName`, `shadow` and `seed` to Paper. A paper clip is set between the next-month arrow and the caption (not on the arrow); `fastenerClassName` moves it.
seedstring | number-Pins the hand: the same seed always rules the same grid.
componentsPartial<CustomComponents>-Swap any DayPicker part; yours are merged over ours.
classNamesPartial<ClassNames>-Same keys as upstream shadcn (`root`, `months`, `month`, `nav`, `month_caption`, `weekday`, `day`, `today`, `range_start`, ...); merged over the defaults.

无障碍

  • The month is a `role=grid` table named by its caption, days are buttons with the full date as their name ("Today, Thursday, September 17th, 2026, selected"), and the selected cell has `aria-selected`. Today also carries `aria-current="date"`. All of that is react-day-picker's.
  • One day is the tab stop (roving tabindex). Arrow keys move by day and week, Home and End to the week edge, PageUp / PageDown by month, Shift with them by year, Enter and Space select. Right-to-left swaps the horizontal arrows.
  • The previous / next buttons keep `aria-disabled` (not `disabled`) at the end of `startMonth` / `endMonth`, so focus is not lost when you reach the limit.
  • Nothing depends on hue alone: the chosen day is circled and bold, a range is a swipe with bold ends, a disabled day is hatched (and unclickable), today is underlined, and focus is a drawn blue loop that bleeds past the cell. The month caption is a polite live region, so paging announces the new month.
  • Touch: a day is 40 px by default, 34 px in compact density and 30 px in calm. In a space narrower than the month the days shrink but stay square, so the ruled lines always fall between them, and several months stack instead of squeezing side by side.
  • Forced colors (Windows high contrast): the masks give way to real borders: a border round the chosen day, top and bottom borders on a range, an underline for today, a line-through for disabled days and a Highlight outline for focus.
  • Reduced motion: month changes do not animate (`animate` is off by default).

源码

CLI 会复制进你项目的文件。

正在加载源码