@ui-sdk/react 0.0.0-stage → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/accordion.d.ts +331 -0
  4. package/dist/accordion.js +25 -0
  5. package/dist/agent.d.ts +2 -0
  6. package/dist/agent.js +8 -0
  7. package/dist/alert-dialog.d.ts +56 -0
  8. package/dist/alert-dialog.js +45 -0
  9. package/dist/async-options.d.ts +22 -0
  10. package/dist/async-options.js +56 -0
  11. package/dist/autocomplete.d.ts +102 -0
  12. package/dist/autocomplete.js +195 -0
  13. package/dist/avatar.d.ts +301 -0
  14. package/dist/avatar.js +17 -0
  15. package/dist/button.d.ts +21 -0
  16. package/dist/button.js +45 -0
  17. package/dist/calendar-context.d.ts +10 -0
  18. package/dist/calendar-context.js +9 -0
  19. package/dist/calendar.d.ts +80 -0
  20. package/dist/calendar.js +257 -0
  21. package/dist/carousel.d.ts +52 -0
  22. package/dist/carousel.js +151 -0
  23. package/dist/checkbox.d.ts +24 -0
  24. package/dist/checkbox.js +98 -0
  25. package/dist/children.d.ts +38 -0
  26. package/dist/children.js +63 -0
  27. package/dist/collapsible.d.ts +302 -0
  28. package/dist/collapsible.js +19 -0
  29. package/dist/color-picker.d.ts +72 -0
  30. package/dist/color-picker.js +133 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +22 -0
  33. package/dist/combobox.d.ts +152 -0
  34. package/dist/combobox.js +338 -0
  35. package/dist/command.d.ts +88 -0
  36. package/dist/command.js +233 -0
  37. package/dist/controller-target.d.ts +3 -0
  38. package/dist/controller-target.js +59 -0
  39. package/dist/date-input.d.ts +19 -0
  40. package/dist/date-input.js +58 -0
  41. package/dist/date-picker.d.ts +47 -0
  42. package/dist/date-picker.js +310 -0
  43. package/dist/date.d.ts +2 -0
  44. package/dist/date.js +60 -0
  45. package/dist/dialog-parts.d.ts +23 -0
  46. package/dist/dialog-parts.js +142 -0
  47. package/dist/dialog.d.ts +57 -0
  48. package/dist/dialog.js +32 -0
  49. package/dist/drawer.d.ts +70 -0
  50. package/dist/drawer.js +158 -0
  51. package/dist/editor-context.d.ts +4 -0
  52. package/dist/editor-context.js +9 -0
  53. package/dist/field-context.d.ts +47 -0
  54. package/dist/field-context.js +87 -0
  55. package/dist/field.d.ts +49 -0
  56. package/dist/field.js +169 -0
  57. package/dist/file-input.d.ts +46 -0
  58. package/dist/file-input.js +170 -0
  59. package/dist/form-inputs.d.ts +5 -0
  60. package/dist/form-inputs.js +22 -0
  61. package/dist/gesture.d.ts +1 -0
  62. package/dist/gesture.js +16 -0
  63. package/dist/history.d.ts +2 -0
  64. package/dist/history.js +12 -0
  65. package/dist/hover-card.d.ts +33 -0
  66. package/dist/hover-card.js +84 -0
  67. package/dist/image-cropper.d.ts +333 -0
  68. package/dist/image-cropper.js +37 -0
  69. package/dist/image.d.ts +2 -0
  70. package/dist/image.js +6 -0
  71. package/dist/input.d.ts +22 -0
  72. package/dist/input.js +51 -0
  73. package/dist/label.d.ts +294 -0
  74. package/dist/label.js +9 -0
  75. package/dist/list-items.d.ts +15 -0
  76. package/dist/list-items.js +39 -0
  77. package/dist/list-text.d.ts +4 -0
  78. package/dist/list-text.js +15 -0
  79. package/dist/listbox.d.ts +56 -0
  80. package/dist/listbox.js +122 -0
  81. package/dist/menu.d.ts +116 -0
  82. package/dist/menu.js +426 -0
  83. package/dist/menubar-context.d.ts +4 -0
  84. package/dist/menubar-context.js +7 -0
  85. package/dist/menubar.d.ts +11 -0
  86. package/dist/menubar.js +32 -0
  87. package/dist/meter.d.ts +312 -0
  88. package/dist/meter.js +30 -0
  89. package/dist/navigation-menu.d.ts +61 -0
  90. package/dist/navigation-menu.js +169 -0
  91. package/dist/number-input.d.ts +44 -0
  92. package/dist/number-input.js +185 -0
  93. package/dist/number.d.ts +2 -0
  94. package/dist/number.js +40 -0
  95. package/dist/observe.d.ts +2 -0
  96. package/dist/observe.js +8 -0
  97. package/dist/otp-input.d.ts +29 -0
  98. package/dist/otp-input.js +94 -0
  99. package/dist/overlays.d.ts +26 -0
  100. package/dist/overlays.js +82 -0
  101. package/dist/pagination.d.ts +336 -0
  102. package/dist/pagination.js +71 -0
  103. package/dist/password-input.d.ts +23 -0
  104. package/dist/password-input.js +65 -0
  105. package/dist/popover.d.ts +54 -0
  106. package/dist/popover.js +151 -0
  107. package/dist/popup.d.ts +41 -0
  108. package/dist/popup.js +180 -0
  109. package/dist/preferences.d.ts +35 -0
  110. package/dist/preferences.js +93 -0
  111. package/dist/primitive.d.ts +2 -0
  112. package/dist/primitive.js +14 -0
  113. package/dist/progress.d.ts +312 -0
  114. package/dist/progress.js +30 -0
  115. package/dist/radio.d.ts +22 -0
  116. package/dist/radio.js +86 -0
  117. package/dist/rating.d.ts +20 -0
  118. package/dist/rating.js +94 -0
  119. package/dist/render-element.d.ts +35 -0
  120. package/dist/render-element.js +103 -0
  121. package/dist/resizable.d.ts +302 -0
  122. package/dist/resizable.js +23 -0
  123. package/dist/scroll-area.d.ts +324 -0
  124. package/dist/scroll-area.js +49 -0
  125. package/dist/segmented-control.d.ts +24 -0
  126. package/dist/segmented-control.js +78 -0
  127. package/dist/segmented-input.d.ts +15 -0
  128. package/dist/segmented-input.js +48 -0
  129. package/dist/select.d.ts +125 -0
  130. package/dist/select.js +330 -0
  131. package/dist/separator.d.ts +290 -0
  132. package/dist/separator.js +9 -0
  133. package/dist/shortcuts.d.ts +32 -0
  134. package/dist/shortcuts.js +61 -0
  135. package/dist/slider.d.ts +38 -0
  136. package/dist/slider.js +163 -0
  137. package/dist/switch.d.ts +15 -0
  138. package/dist/switch.js +39 -0
  139. package/dist/tabs.d.ts +331 -0
  140. package/dist/tabs.js +28 -0
  141. package/dist/text-control.d.ts +22 -0
  142. package/dist/text-control.js +24 -0
  143. package/dist/text-match.d.ts +2 -0
  144. package/dist/text-match.js +8 -0
  145. package/dist/textarea.d.ts +10 -0
  146. package/dist/textarea.js +48 -0
  147. package/dist/time-input.d.ts +19 -0
  148. package/dist/time-input.js +63 -0
  149. package/dist/timeline.d.ts +327 -0
  150. package/dist/timeline.js +31 -0
  151. package/dist/toast-parts.d.ts +63 -0
  152. package/dist/toast-parts.js +144 -0
  153. package/dist/toast.d.ts +2 -0
  154. package/dist/toast.js +22 -0
  155. package/dist/toggle.d.ts +23 -0
  156. package/dist/toggle.js +76 -0
  157. package/dist/token-input.d.ts +35 -0
  158. package/dist/token-input.js +100 -0
  159. package/dist/toolbar-context.d.ts +6 -0
  160. package/dist/toolbar-context.js +16 -0
  161. package/dist/toolbar.d.ts +38 -0
  162. package/dist/toolbar.js +63 -0
  163. package/dist/tooltip.d.ts +39 -0
  164. package/dist/tooltip.js +108 -0
  165. package/dist/tree.d.ts +51 -0
  166. package/dist/tree.js +150 -0
  167. package/dist/trigger-menu.d.ts +83 -0
  168. package/dist/trigger-menu.js +167 -0
  169. package/dist/use-primitive.d.ts +178 -0
  170. package/dist/use-primitive.js +674 -0
  171. package/dist/waterfall.d.ts +80 -0
  172. package/dist/waterfall.js +108 -0
  173. package/docs/README.md +89 -0
  174. package/docs/agents.md +1523 -0
  175. package/docs/components/accordion.md +1391 -0
  176. package/docs/components/alert-dialog.md +850 -0
  177. package/docs/components/autocomplete.md +1963 -0
  178. package/docs/components/avatar.md +252 -0
  179. package/docs/components/button.md +444 -0
  180. package/docs/components/calendar.md +1687 -0
  181. package/docs/components/carousel.md +1244 -0
  182. package/docs/components/checkbox.md +1069 -0
  183. package/docs/components/collapsible.md +567 -0
  184. package/docs/components/color-picker.md +736 -0
  185. package/docs/components/combobox.md +3647 -0
  186. package/docs/components/command.md +1573 -0
  187. package/docs/components/date-input.md +608 -0
  188. package/docs/components/date-picker.md +1266 -0
  189. package/docs/components/dialog.md +1469 -0
  190. package/docs/components/drawer.md +1197 -0
  191. package/docs/components/field.md +549 -0
  192. package/docs/components/file-input.md +609 -0
  193. package/docs/components/hover-card.md +514 -0
  194. package/docs/components/image-cropper.md +579 -0
  195. package/docs/components/input.md +301 -0
  196. package/docs/components/label.md +217 -0
  197. package/docs/components/listbox.md +1130 -0
  198. package/docs/components/menu.md +1286 -0
  199. package/docs/components/menubar.md +455 -0
  200. package/docs/components/meter.md +304 -0
  201. package/docs/components/navigation-menu.md +1581 -0
  202. package/docs/components/number-input.md +1086 -0
  203. package/docs/components/otp-input.md +565 -0
  204. package/docs/components/pagination.md +648 -0
  205. package/docs/components/password-input.md +737 -0
  206. package/docs/components/popover.md +1552 -0
  207. package/docs/components/preferences.md +220 -0
  208. package/docs/components/progress.md +443 -0
  209. package/docs/components/radio.md +846 -0
  210. package/docs/components/rating.md +458 -0
  211. package/docs/components/resizable.md +982 -0
  212. package/docs/components/scroll-area.md +980 -0
  213. package/docs/components/segmented-control.md +465 -0
  214. package/docs/components/select.md +2133 -0
  215. package/docs/components/separator.md +243 -0
  216. package/docs/components/slider.md +1169 -0
  217. package/docs/components/switch.md +613 -0
  218. package/docs/components/tabs.md +1014 -0
  219. package/docs/components/textarea.md +318 -0
  220. package/docs/components/time-input.md +231 -0
  221. package/docs/components/timeline.md +677 -0
  222. package/docs/components/toast.md +1395 -0
  223. package/docs/components/toggle.md +541 -0
  224. package/docs/components/token-input.md +1007 -0
  225. package/docs/components/toolbar.md +787 -0
  226. package/docs/components/tooltip.md +884 -0
  227. package/docs/components/tree.md +1346 -0
  228. package/docs/components/trigger-menu.md +1257 -0
  229. package/docs/components/waterfall.md +754 -0
  230. package/docs/controllers.md +89 -0
  231. package/docs/core.md +8027 -0
  232. package/docs/custom-parts.md +120 -0
  233. package/docs/first-component.md +83 -0
  234. package/docs/forms.md +148 -0
  235. package/docs/hooks/async-options.md +366 -0
  236. package/docs/hooks/shortcuts.md +221 -0
  237. package/docs/installation.md +45 -0
  238. package/docs/introduction.md +32 -0
  239. package/docs/lists-and-menus.md +170 -0
  240. package/docs/llms.txt +1844 -0
  241. package/docs/parts-and-composition.md +93 -0
  242. package/docs/popups.md +117 -0
  243. package/docs/rendering.md +121 -0
  244. package/docs/server-rendering.md +253 -0
  245. package/docs/state-and-events.md +105 -0
  246. package/docs/styling-and-animation.md +176 -0
  247. package/package.json +333 -3
@@ -0,0 +1,1687 @@
1
+ # Calendar
2
+
3
+ Choose one date, several dates, or a range from a month grid.
4
+
5
+ Calendar shows dates directly on the page. Use it for a booking flow, a schedule, or any place where the dates should stay visible. For a text field that opens a calendar, use [Date Picker](./date-picker.md).
6
+
7
+ ```tsx title="basic.tsx"
8
+ "use client"
9
+
10
+ import {
11
+ Calendar,
12
+ CalendarDay,
13
+ CalendarGrid,
14
+ CalendarHeading,
15
+ CalendarNext,
16
+ CalendarPrevious,
17
+ CalendarWeekday,
18
+ CalendarWeekdays,
19
+ CalendarWeeks,
20
+ } from "@ui-sdk/react/calendar"
21
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
22
+
23
+ function Example() {
24
+ return (
25
+ <Calendar defaultValue="2026-10-16">
26
+ <div data-slot="row">
27
+ <CalendarPrevious data-variant="ghost">
28
+ <ChevronLeftIcon aria-hidden="true" />
29
+ </CalendarPrevious>
30
+ <CalendarHeading />
31
+ <CalendarNext data-variant="ghost">
32
+ <ChevronRightIcon aria-hidden="true" />
33
+ </CalendarNext>
34
+ </div>
35
+ <CalendarGrid>
36
+ <CalendarWeekdays>
37
+ {(index) => <CalendarWeekday index={index} />}
38
+ </CalendarWeekdays>
39
+ <CalendarWeeks>
40
+ {(cell) => <CalendarDay value={cell.date} />}
41
+ </CalendarWeeks>
42
+ </CalendarGrid>
43
+ </Calendar>
44
+ )
45
+ }
46
+
47
+ export { Example }
48
+ ```
49
+
50
+ Choose a date, then use Previous or Next to change the month. Arrow keys move through the days.
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ npm install @ui-sdk/react @ui-sdk/core
56
+ ```
57
+
58
+ ## Composition
59
+
60
+ Use the following composition to build a `Calendar`:
61
+
62
+ ```text
63
+ Calendar
64
+ ├── CalendarPrevious
65
+ ├── CalendarHeading
66
+ ├── CalendarNext
67
+ └── CalendarGrid
68
+ ├── CalendarWeekdays
69
+ │ └── CalendarWeekday
70
+ └── CalendarWeeks
71
+ └── CalendarDay
72
+ ```
73
+
74
+ The heading names the displayed month. Previous and Next change it, and a grid holds its weekday headers and dates. The weekday and week helpers render the table structure, while you render each header and date.
75
+
76
+ An empty `Calendar` renders the default structure, and an empty `CalendarGrid` renders its headers and weeks. Write the parts out to add your classes and content. Each grid is named by its month and has the `grid` role.
77
+
78
+ ## Usage
79
+
80
+ Import the parts and put them together:
81
+
82
+ ```tsx
83
+ import {
84
+ Calendar,
85
+ CalendarDay,
86
+ CalendarGrid,
87
+ CalendarHeading,
88
+ CalendarNext,
89
+ CalendarPrevious,
90
+ CalendarWeekday,
91
+ CalendarWeekdays,
92
+ CalendarWeeks,
93
+ } from "@ui-sdk/react/calendar"
94
+
95
+ function Example() {
96
+ return (
97
+ <Calendar defaultValue="2026-10-16">
98
+ <CalendarPrevious />
99
+ <CalendarHeading />
100
+ <CalendarNext />
101
+ <CalendarGrid>
102
+ <CalendarWeekdays>
103
+ {(index) => <CalendarWeekday index={index} />}
104
+ </CalendarWeekdays>
105
+ <CalendarWeeks>
106
+ {(cell) => <CalendarDay value={cell.date} />}
107
+ </CalendarWeeks>
108
+ </CalendarGrid>
109
+ </Calendar>
110
+ )
111
+ }
112
+
113
+ export { Example }
114
+ ```
115
+
116
+ ## Values
117
+
118
+ Dates are ISO strings such as `"2026-10-16"`, with no time or time zone attached. No date library is needed. The [date helpers](../core.md#dates) handle arithmetic; `Intl` formats names and labels.
119
+
120
+ | Mode | Value |
121
+ | -------------------- | ------------------------------- |
122
+ | `"single"` (default) | A date string or `null`. |
123
+ | `"multiple"` | A sorted array of date strings. |
124
+ | `"range"` | `[start, end]` or `null`. |
125
+
126
+ A value with the wrong shape for its mode is treated as no selection.
127
+
128
+ ## Range
129
+
130
+ `mode="range"` chooses a start and then an end. Moving the pointer or focus previews the range; the value changes once both ends are chosen. A date before the start ends it too, and becomes the start. Escape cancels an unfinished range.
131
+
132
+ ```tsx title="range.tsx"
133
+ "use client"
134
+
135
+ import {
136
+ Calendar,
137
+ CalendarDay,
138
+ CalendarGrid,
139
+ CalendarHeading,
140
+ CalendarNext,
141
+ CalendarPrevious,
142
+ CalendarWeekday,
143
+ CalendarWeekdays,
144
+ CalendarWeeks,
145
+ } from "@ui-sdk/react/calendar"
146
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
147
+
148
+ function Example() {
149
+ return (
150
+ <Calendar mode="range" months={2} monthFormat="short" defaultValue={["2026-10-12", "2026-10-16"]}>
151
+ <div data-slot="row">
152
+ <CalendarPrevious data-variant="ghost">
153
+ <ChevronLeftIcon aria-hidden="true" />
154
+ </CalendarPrevious>
155
+ <CalendarHeading />
156
+ <CalendarNext data-variant="ghost">
157
+ <ChevronRightIcon aria-hidden="true" />
158
+ </CalendarNext>
159
+ </div>
160
+ <div data-slot="row">
161
+ <CalendarGrid offset={0}>
162
+ <CalendarWeekdays>
163
+ {(index) => <CalendarWeekday index={index} />}
164
+ </CalendarWeekdays>
165
+ <CalendarWeeks>
166
+ {(cell) => <CalendarDay value={cell.date} />}
167
+ </CalendarWeeks>
168
+ </CalendarGrid>
169
+ <CalendarGrid offset={1}>
170
+ <CalendarWeekdays>
171
+ {(index) => <CalendarWeekday index={index} />}
172
+ </CalendarWeekdays>
173
+ <CalendarWeeks>
174
+ {(cell) => <CalendarDay value={cell.date} />}
175
+ </CalendarWeeks>
176
+ </CalendarGrid>
177
+ </div>
178
+ </Calendar>
179
+ )
180
+ }
181
+
182
+ export { Example }
183
+ ```
184
+
185
+ Choose a start date, then move to an end date to preview the range. Choose the end to finish, or press Escape to cancel the unfinished range.
186
+
187
+ ## Multiple
188
+
189
+ `mode="multiple"` toggles each date independently. Its value is a sorted array, even when dates were chosen in another order.
190
+
191
+ ```tsx title="multiple.tsx"
192
+ "use client"
193
+
194
+ import {
195
+ Calendar,
196
+ CalendarDay,
197
+ CalendarGrid,
198
+ CalendarHeading,
199
+ CalendarNext,
200
+ CalendarPrevious,
201
+ CalendarWeekday,
202
+ CalendarWeekdays,
203
+ CalendarWeeks,
204
+ } from "@ui-sdk/react/calendar"
205
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
206
+ import * as React from "react"
207
+
208
+ function Example() {
209
+ const [dates, setDates] = React.useState<string[]>([
210
+ "2026-10-07",
211
+ "2026-10-16",
212
+ "2026-10-26",
213
+ ])
214
+ return (
215
+ <div>
216
+ <Calendar
217
+ mode="multiple"
218
+ value={dates}
219
+ onValueChange={(value) => setDates(value as string[])}
220
+ >
221
+ <div data-slot="row">
222
+ <CalendarPrevious data-variant="ghost">
223
+ <ChevronLeftIcon aria-hidden="true" />
224
+ </CalendarPrevious>
225
+ <CalendarHeading />
226
+ <CalendarNext data-variant="ghost">
227
+ <ChevronRightIcon aria-hidden="true" />
228
+ </CalendarNext>
229
+ </div>
230
+ <CalendarGrid>
231
+ <CalendarWeekdays>
232
+ {(index) => <CalendarWeekday index={index} />}
233
+ </CalendarWeekdays>
234
+ <CalendarWeeks>
235
+ {(cell) => <CalendarDay value={cell.date} />}
236
+ </CalendarWeeks>
237
+ </CalendarGrid>
238
+ </Calendar>
239
+ </div>
240
+ )
241
+ }
242
+
243
+ export { Example }
244
+ ```
245
+
246
+ Choose another date to add it, or choose a selected date to remove it.
247
+
248
+ ## Unavailable Dates
249
+
250
+ `unavailable` accepts a date, `{ from, to }`, `{ weekday: [0, 6] }` for weekends, `{ before }`, `{ after }`, a predicate, or an array of these matchers. Weekday zero is Sunday.
251
+
252
+ Unavailable dates cannot be selected, but stay focusable so keyboard and screen reader users can discover them. They expose `aria-disabled` and `data-unavailable`.
253
+
254
+ ```tsx title="unavailable.tsx"
255
+ "use client"
256
+
257
+ import {
258
+ Calendar,
259
+ CalendarDay,
260
+ CalendarGrid,
261
+ CalendarHeading,
262
+ CalendarNext,
263
+ CalendarPrevious,
264
+ CalendarWeekday,
265
+ CalendarWeekdays,
266
+ CalendarWeeks,
267
+ } from "@ui-sdk/react/calendar"
268
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
269
+
270
+ const unavailable = [
271
+ "2026-10-08",
272
+ { from: "2026-10-20", to: "2026-10-23" },
273
+ { weekday: [0, 6] },
274
+ ]
275
+
276
+ function Example() {
277
+ return (
278
+ <Calendar unavailable={unavailable}>
279
+ <div data-slot="row">
280
+ <CalendarPrevious data-variant="ghost">
281
+ <ChevronLeftIcon aria-hidden="true" />
282
+ </CalendarPrevious>
283
+ <CalendarHeading />
284
+ <CalendarNext data-variant="ghost">
285
+ <ChevronRightIcon aria-hidden="true" />
286
+ </CalendarNext>
287
+ </div>
288
+ <CalendarGrid>
289
+ <CalendarWeekdays>
290
+ {(index) => <CalendarWeekday index={index} />}
291
+ </CalendarWeekdays>
292
+ <CalendarWeeks>
293
+ {(cell) => <CalendarDay value={cell.date} />}
294
+ </CalendarWeeks>
295
+ </CalendarGrid>
296
+ </Calendar>
297
+ )
298
+ }
299
+
300
+ export { Example }
301
+ ```
302
+
303
+ Try an unavailable date, then choose an available one. Unavailable days remain focusable so their state can be heard.
304
+
305
+ ## Deselect
306
+
307
+ `deselectable` lets a second press on the selected date clear it, in single mode. Without it, a second press keeps the date selected.
308
+
309
+ ## Min and Max
310
+
311
+ `min` and `max` set the earliest and latest selectable dates. Dates outside those bounds cannot receive focus. Arrow keys stop at the bounds, and Previous and Next stop at their months.
312
+
313
+ ```tsx title="min-max.tsx"
314
+ "use client"
315
+
316
+ import {
317
+ Calendar,
318
+ CalendarDay,
319
+ CalendarGrid,
320
+ CalendarHeading,
321
+ CalendarNext,
322
+ CalendarPrevious,
323
+ CalendarWeekday,
324
+ CalendarWeekdays,
325
+ CalendarWeeks,
326
+ } from "@ui-sdk/react/calendar"
327
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
328
+
329
+ function Example() {
330
+ return (
331
+ <Calendar defaultValue="2026-10-16" min="2026-10-05" max="2026-11-20">
332
+ <div data-slot="row">
333
+ <CalendarPrevious data-variant="ghost">
334
+ <ChevronLeftIcon aria-hidden="true" />
335
+ </CalendarPrevious>
336
+ <CalendarHeading />
337
+ <CalendarNext data-variant="ghost">
338
+ <ChevronRightIcon aria-hidden="true" />
339
+ </CalendarNext>
340
+ </div>
341
+ <CalendarGrid>
342
+ <CalendarWeekdays>
343
+ {(index) => <CalendarWeekday index={index} />}
344
+ </CalendarWeekdays>
345
+ <CalendarWeeks>
346
+ {(cell) => <CalendarDay value={cell.date} />}
347
+ </CalendarWeeks>
348
+ </CalendarGrid>
349
+ </Calendar>
350
+ )
351
+ }
352
+
353
+ export { Example }
354
+ ```
355
+
356
+ Move toward either end of the allowed dates. Keyboard navigation and month buttons stop at the limits.
357
+
358
+ ## Disabled and Read Only
359
+
360
+ `disabled` prevents focus, selection, and month navigation. `readOnly` allows navigation so dates can be inspected, but keeps the selected value unchanged.
361
+
362
+ ```tsx title="disabled.tsx"
363
+ "use client"
364
+
365
+ import {
366
+ Calendar,
367
+ CalendarDay,
368
+ CalendarGrid,
369
+ CalendarHeading,
370
+ CalendarNext,
371
+ CalendarPrevious,
372
+ CalendarWeekday,
373
+ CalendarWeekdays,
374
+ CalendarWeeks,
375
+ } from "@ui-sdk/react/calendar"
376
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
377
+
378
+ function Example() {
379
+ return (
380
+ <Calendar disabled defaultValue="2026-10-16">
381
+ <div data-slot="row">
382
+ <CalendarPrevious data-variant="ghost">
383
+ <ChevronLeftIcon aria-hidden="true" />
384
+ </CalendarPrevious>
385
+ <CalendarHeading />
386
+ <CalendarNext data-variant="ghost">
387
+ <ChevronRightIcon aria-hidden="true" />
388
+ </CalendarNext>
389
+ </div>
390
+ <CalendarGrid>
391
+ <CalendarWeekdays>
392
+ {(index) => <CalendarWeekday index={index} />}
393
+ </CalendarWeekdays>
394
+ <CalendarWeeks>
395
+ {(cell) => <CalendarDay value={cell.date} />}
396
+ </CalendarWeeks>
397
+ </CalendarGrid>
398
+ </Calendar>
399
+ )
400
+ }
401
+
402
+ export { Example }
403
+ ```
404
+
405
+ Try choosing a date or changing months. A disabled calendar has no available controls.
406
+
407
+ ```tsx title="read-only.tsx"
408
+ "use client"
409
+
410
+ import {
411
+ Calendar,
412
+ CalendarDay,
413
+ CalendarGrid,
414
+ CalendarHeading,
415
+ CalendarNext,
416
+ CalendarPrevious,
417
+ CalendarWeekday,
418
+ CalendarWeekdays,
419
+ CalendarWeeks,
420
+ } from "@ui-sdk/react/calendar"
421
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
422
+
423
+ function Example() {
424
+ return (
425
+ <Calendar readOnly defaultValue="2026-10-16">
426
+ <div data-slot="row">
427
+ <CalendarPrevious data-variant="ghost">
428
+ <ChevronLeftIcon aria-hidden="true" />
429
+ </CalendarPrevious>
430
+ <CalendarHeading />
431
+ <CalendarNext data-variant="ghost">
432
+ <ChevronRightIcon aria-hidden="true" />
433
+ </CalendarNext>
434
+ </div>
435
+ <CalendarGrid>
436
+ <CalendarWeekdays>
437
+ {(index) => <CalendarWeekday index={index} />}
438
+ </CalendarWeekdays>
439
+ <CalendarWeeks>
440
+ {(cell) => <CalendarDay value={cell.date} />}
441
+ </CalendarWeeks>
442
+ </CalendarGrid>
443
+ </Calendar>
444
+ )
445
+ }
446
+
447
+ export { Example }
448
+ ```
449
+
450
+ Move through dates and months. The selected value stays unchanged.
451
+
452
+ ## Two Months
453
+
454
+ Set `months` to `2` and render grids with offsets `0` and `1`. Arrow keys move between the grids without turning the page. Dates that another visible month already shows leave an empty cell, so each date appears once.
455
+
456
+ `pageBy="page"` makes Previous, Next, and navigation beyond the visible grids move by the full number of months.
457
+
458
+ ```tsx title="two-months.tsx"
459
+ "use client"
460
+
461
+ import {
462
+ Calendar,
463
+ CalendarDay,
464
+ CalendarGrid,
465
+ CalendarHeading,
466
+ CalendarNext,
467
+ CalendarPrevious,
468
+ CalendarWeekday,
469
+ CalendarWeekdays,
470
+ CalendarWeeks,
471
+ } from "@ui-sdk/react/calendar"
472
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
473
+
474
+ function Example() {
475
+ return (
476
+ <Calendar months={2} pageBy="page" monthFormat="short" defaultValue="2026-10-16">
477
+ <div data-slot="row">
478
+ <CalendarPrevious data-variant="ghost">
479
+ <ChevronLeftIcon aria-hidden="true" />
480
+ </CalendarPrevious>
481
+ <CalendarHeading />
482
+ <CalendarNext data-variant="ghost">
483
+ <ChevronRightIcon aria-hidden="true" />
484
+ </CalendarNext>
485
+ </div>
486
+ <div data-slot="row">
487
+ <CalendarGrid offset={0}>
488
+ <CalendarWeekdays>
489
+ {(index) => <CalendarWeekday index={index} />}
490
+ </CalendarWeekdays>
491
+ <CalendarWeeks>
492
+ {(cell) => <CalendarDay value={cell.date} />}
493
+ </CalendarWeeks>
494
+ </CalendarGrid>
495
+ <CalendarGrid offset={1}>
496
+ <CalendarWeekdays>
497
+ {(index) => <CalendarWeekday index={index} />}
498
+ </CalendarWeekdays>
499
+ <CalendarWeeks>
500
+ {(cell) => <CalendarDay value={cell.date} />}
501
+ </CalendarWeeks>
502
+ </CalendarGrid>
503
+ </div>
504
+ </Calendar>
505
+ )
506
+ }
507
+
508
+ export { Example }
509
+ ```
510
+
511
+ Move between October and November with arrow keys. Next advances both visible months to December and January.
512
+
513
+ ## Fixed Weeks
514
+
515
+ `fixedWeeks` renders six week rows in every month. Set `showOutsideDays` to `false` to leave dates from neighboring months blank.
516
+
517
+ ```tsx title="fixed-weeks.tsx"
518
+ "use client"
519
+
520
+ import {
521
+ Calendar,
522
+ CalendarDay,
523
+ CalendarGrid,
524
+ CalendarHeading,
525
+ CalendarNext,
526
+ CalendarPrevious,
527
+ CalendarWeekday,
528
+ CalendarWeekdays,
529
+ CalendarWeeks,
530
+ } from "@ui-sdk/react/calendar"
531
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
532
+
533
+ function Example() {
534
+ return (
535
+ <Calendar fixedWeeks showOutsideDays={false} defaultMonth="2026-02">
536
+ <div data-slot="row">
537
+ <CalendarPrevious data-variant="ghost">
538
+ <ChevronLeftIcon aria-hidden="true" />
539
+ </CalendarPrevious>
540
+ <CalendarHeading />
541
+ <CalendarNext data-variant="ghost">
542
+ <ChevronRightIcon aria-hidden="true" />
543
+ </CalendarNext>
544
+ </div>
545
+ <CalendarGrid>
546
+ <CalendarWeekdays>
547
+ {(index) => <CalendarWeekday index={index} />}
548
+ </CalendarWeekdays>
549
+ <CalendarWeeks>
550
+ {(cell) => <CalendarDay value={cell.date} />}
551
+ </CalendarWeeks>
552
+ </CalendarGrid>
553
+ </Calendar>
554
+ )
555
+ }
556
+
557
+ export { Example }
558
+ ```
559
+
560
+ Move from February to March. Both grids keep six week rows, and dates outside each month are hidden.
561
+
562
+ ## Month and Year Selects
563
+
564
+ `CalendarMonthSelect` and `CalendarYearSelect` are native selects for jumping directly to a date, such as a birthday. The year options run from `min` to `max`, or ten years either side of the current year shown when bounds are missing. Months outside the bounds are disabled.
565
+
566
+ They update the first displayed month with the `select-change` reason. Their state exposes the options if you want to render a different select.
567
+
568
+ ```tsx title="month-year-select.tsx"
569
+ "use client"
570
+
571
+ import {
572
+ Calendar,
573
+ CalendarDay,
574
+ CalendarGrid,
575
+ CalendarHeading,
576
+ CalendarMonthSelect,
577
+ CalendarNext,
578
+ CalendarPrevious,
579
+ CalendarWeekday,
580
+ CalendarWeekdays,
581
+ CalendarWeeks,
582
+ CalendarYearSelect,
583
+ } from "@ui-sdk/react/calendar"
584
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
585
+
586
+ function Example() {
587
+ return (
588
+ <Calendar defaultMonth="1990-06" min="1920-01-01" max="2026-10-16">
589
+ <div data-slot="row">
590
+ <CalendarPrevious data-variant="ghost">
591
+ <ChevronLeftIcon aria-hidden="true" />
592
+ </CalendarPrevious>
593
+ <CalendarHeading />
594
+ <div data-slot="row">
595
+ <CalendarMonthSelect />
596
+ <CalendarYearSelect />
597
+ </div>
598
+ <CalendarNext data-variant="ghost">
599
+ <ChevronRightIcon aria-hidden="true" />
600
+ </CalendarNext>
601
+ </div>
602
+ <CalendarGrid>
603
+ <CalendarWeekdays>
604
+ {(index) => <CalendarWeekday index={index} />}
605
+ </CalendarWeekdays>
606
+ <CalendarWeeks>
607
+ {(cell) => <CalendarDay value={cell.date} />}
608
+ </CalendarWeeks>
609
+ </CalendarGrid>
610
+ </Calendar>
611
+ )
612
+ }
613
+
614
+ export { Example }
615
+ ```
616
+
617
+ Choose a year and month to jump directly to a birthday, then choose the day.
618
+
619
+ ## Custom Month and Year Selects
620
+
621
+ The month and year selects are native `select` elements. To use your own select, control the calendar's `month` and drive it from your select's value, as with the [Select](./select.md) component here. Keep a `CalendarHeading` in the calendar, visually hidden if you like, so the grid stays named.
622
+
623
+ ```tsx title="custom-select.tsx"
624
+ "use client"
625
+
626
+ import {
627
+ Calendar,
628
+ CalendarDay,
629
+ CalendarGrid,
630
+ CalendarHeading,
631
+ CalendarWeekday,
632
+ CalendarWeekdays,
633
+ CalendarWeeks,
634
+ } from "@ui-sdk/react/calendar"
635
+ import {
636
+ Select,
637
+ SelectContent,
638
+ SelectItem,
639
+ SelectItemIndicator,
640
+ SelectTrigger,
641
+ SelectValue,
642
+ } from "@ui-sdk/react/select"
643
+ import { CheckIcon, ChevronDownIcon } from "lucide-react"
644
+ import * as React from "react"
645
+
646
+ const months = [
647
+ "January",
648
+ "February",
649
+ "March",
650
+ "April",
651
+ "May",
652
+ "June",
653
+ "July",
654
+ "August",
655
+ "September",
656
+ "October",
657
+ "November",
658
+ "December",
659
+ ].map((label, index) => ({ value: String(index + 1).padStart(2, "0"), label }))
660
+ const years = ["2024", "2025", "2026", "2027", "2028"].map((year) => ({
661
+ value: year,
662
+ label: year,
663
+ }))
664
+
665
+ function Example() {
666
+ const [month, setMonth] = React.useState("2026-10")
667
+ const [year, monthOfYear] = month.split("-")
668
+
669
+ return (
670
+ <Calendar
671
+ month={month}
672
+ onMonthChange={setMonth}
673
+ defaultValue="2026-10-16"
674
+ min="2024-01-01"
675
+ max="2028-12-31"
676
+ >
677
+ <div data-slot="row">
678
+ <CalendarHeading />
679
+ <Select
680
+ items={months}
681
+ value={monthOfYear}
682
+ onValueChange={(next) => next && setMonth(`${year}-${next}`)}
683
+ >
684
+ <SelectTrigger aria-label="Month">
685
+ <SelectValue />
686
+ <ChevronDownIcon />
687
+ </SelectTrigger>
688
+ <SelectContent>
689
+ {months.map((option) => (
690
+ <SelectItem key={option.value} value={option.value}>
691
+ {option.label}
692
+ <SelectItemIndicator>
693
+ <CheckIcon />
694
+ </SelectItemIndicator>
695
+ </SelectItem>
696
+ ))}
697
+ </SelectContent>
698
+ </Select>
699
+ <Select
700
+ items={years}
701
+ value={year}
702
+ onValueChange={(next) => next && setMonth(`${next}-${monthOfYear}`)}
703
+ >
704
+ <SelectTrigger aria-label="Year">
705
+ <SelectValue />
706
+ <ChevronDownIcon />
707
+ </SelectTrigger>
708
+ <SelectContent>
709
+ {years.map((option) => (
710
+ <SelectItem key={option.value} value={option.value}>
711
+ {option.label}
712
+ <SelectItemIndicator>
713
+ <CheckIcon />
714
+ </SelectItemIndicator>
715
+ </SelectItem>
716
+ ))}
717
+ </SelectContent>
718
+ </Select>
719
+ </div>
720
+ <CalendarGrid>
721
+ <CalendarWeekdays>
722
+ {(index) => <CalendarWeekday index={index} />}
723
+ </CalendarWeekdays>
724
+ <CalendarWeeks>
725
+ {(cell) => <CalendarDay value={cell.date} />}
726
+ </CalendarWeeks>
727
+ </CalendarGrid>
728
+ </Calendar>
729
+ )
730
+ }
731
+
732
+ export { Example }
733
+ ```
734
+
735
+ Choose a month or a year from the selects. The calendar follows, and the arrow keys still move between days.
736
+
737
+ ## Language
738
+
739
+ `locale` controls month names, weekday headers, and full date labels. If you omit it, Calendar reads the surrounding page’s `lang` after it mounts, with the browser’s language as a fallback. The initial server and client render use English, so they always match. The first weekday follows the locale, and so changes after mount too, unless `weekStartsOn` sets it. `weekdayFormat` accepts `"narrow"`, `"short"`, or `"long"`.
740
+
741
+ Previous and Next are named "Previous month" and "Next month". Pass `aria-label` to name them in another language. Dates remain Gregorian. Localized year systems, such as Buddhist or Japanese era years, can still appear in the labels.
742
+
743
+ ```tsx title="locale.tsx"
744
+ "use client"
745
+
746
+ import {
747
+ Calendar,
748
+ CalendarDay,
749
+ CalendarGrid,
750
+ CalendarHeading,
751
+ CalendarNext,
752
+ CalendarPrevious,
753
+ CalendarWeekday,
754
+ CalendarWeekdays,
755
+ CalendarWeeks,
756
+ } from "@ui-sdk/react/calendar"
757
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
758
+
759
+ function Example() {
760
+ return (
761
+ <Calendar locale="de-DE" weekStartsOn={1} weekdayFormat="narrow" defaultValue="2026-10-16">
762
+ <div data-slot="row">
763
+ <CalendarPrevious data-variant="ghost">
764
+ <ChevronLeftIcon aria-hidden="true" />
765
+ </CalendarPrevious>
766
+ <CalendarHeading />
767
+ <CalendarNext data-variant="ghost">
768
+ <ChevronRightIcon aria-hidden="true" />
769
+ </CalendarNext>
770
+ </div>
771
+ <CalendarGrid>
772
+ <CalendarWeekdays>
773
+ {(index) => <CalendarWeekday index={index} />}
774
+ </CalendarWeekdays>
775
+ <CalendarWeeks>
776
+ {(cell) => <CalendarDay value={cell.date} />}
777
+ </CalendarWeeks>
778
+ </CalendarGrid>
779
+ </Calendar>
780
+ )
781
+ }
782
+
783
+ export { Example }
784
+ ```
785
+
786
+ Move through the calendar. Month names, weekday headers, and full date labels are in German, with Monday first.
787
+
788
+ ## Name Formats
789
+
790
+ Set `weekdayFormat` for the weekday headers and `monthFormat` for the heading and the month select. Both take `"narrow"`, `"short"` or `"long"`, and follow the calendar's locale. Screen readers still hear full names: the grid and each day keep their long labels.
791
+
792
+ ```tsx title="formats.tsx"
793
+ "use client"
794
+
795
+ import {
796
+ Calendar,
797
+ CalendarDay,
798
+ CalendarGrid,
799
+ CalendarHeading,
800
+ CalendarNext,
801
+ CalendarPrevious,
802
+ CalendarWeekday,
803
+ CalendarWeekdays,
804
+ CalendarWeeks,
805
+ } from "@ui-sdk/react/calendar"
806
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
807
+
808
+ function Example() {
809
+ return (
810
+ <Calendar months={2} pageBy="page" defaultValue="2026-10-16" weekdayFormat="narrow" monthFormat="short">
811
+ <div data-slot="row">
812
+ <CalendarPrevious data-variant="ghost">
813
+ <ChevronLeftIcon aria-hidden="true" />
814
+ </CalendarPrevious>
815
+ <CalendarHeading />
816
+ <CalendarNext data-variant="ghost">
817
+ <ChevronRightIcon aria-hidden="true" />
818
+ </CalendarNext>
819
+ </div>
820
+ <div data-slot="row">
821
+ <CalendarGrid offset={0}>
822
+ <CalendarWeekdays>
823
+ {(index) => <CalendarWeekday index={index} />}
824
+ </CalendarWeekdays>
825
+ <CalendarWeeks>
826
+ {(cell) => <CalendarDay value={cell.date} />}
827
+ </CalendarWeeks>
828
+ </CalendarGrid>
829
+ <CalendarGrid offset={1}>
830
+ <CalendarWeekdays>
831
+ {(index) => <CalendarWeekday index={index} />}
832
+ </CalendarWeekdays>
833
+ <CalendarWeeks>
834
+ {(cell) => <CalendarDay value={cell.date} />}
835
+ </CalendarWeeks>
836
+ </CalendarGrid>
837
+ </div>
838
+ </Calendar>
839
+ )
840
+ }
841
+
842
+ export { Example }
843
+ ```
844
+
845
+ The weekday headers are narrow and the heading uses short month names: Oct – Nov 2026.
846
+
847
+ ## Custom Days
848
+
849
+ A day’s children receive its state, including the date, label, selection, and whether it is outside the month. This example adds a price below each day. Weekday headers can have custom content too.
850
+
851
+ ```tsx title="custom-day.tsx"
852
+ "use client"
853
+
854
+ import {
855
+ Calendar,
856
+ CalendarDay,
857
+ CalendarGrid,
858
+ CalendarHeading,
859
+ CalendarNext,
860
+ CalendarPrevious,
861
+ CalendarWeekday,
862
+ CalendarWeekdays,
863
+ CalendarWeeks,
864
+ } from "@ui-sdk/react/calendar"
865
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
866
+
867
+ const priceOf = (date: string) => 80 + ((Number(date.slice(8)) * 7) % 5) * 10
868
+
869
+ function Example() {
870
+ return (
871
+ <Calendar today="2026-10-16" defaultValue="2026-10-16">
872
+ <div data-slot="row">
873
+ <CalendarPrevious data-variant="ghost">
874
+ <ChevronLeftIcon aria-hidden="true" />
875
+ </CalendarPrevious>
876
+ <CalendarHeading />
877
+ <CalendarNext data-variant="ghost">
878
+ <ChevronRightIcon aria-hidden="true" />
879
+ </CalendarNext>
880
+ </div>
881
+ <CalendarGrid>
882
+ <CalendarWeekdays>
883
+ {(index) => (
884
+ <CalendarWeekday index={index}>
885
+ {(state) => (
886
+ <abbr
887
+ title={state.name}
888
+ data-weekend={
889
+ state.weekday === 0 || state.weekday === 6 || undefined
890
+ }
891
+ >
892
+ {state.label}
893
+ </abbr>
894
+ )}
895
+ </CalendarWeekday>
896
+ )}
897
+ </CalendarWeekdays>
898
+ <CalendarWeeks>
899
+ {(cell) => (
900
+ <CalendarDay value={cell.date}>
901
+ {(state) => (
902
+ <span data-slot="stack">
903
+ <span>{state.label}</span>
904
+ {!state.outside && !state.disabled && (
905
+ <span data-slot="hint">${priceOf(state.date)}</span>
906
+ )}
907
+ </span>
908
+ )}
909
+ </CalendarDay>
910
+ )}
911
+ </CalendarWeeks>
912
+ </CalendarGrid>
913
+ </Calendar>
914
+ )
915
+ }
916
+
917
+ export { Example }
918
+ ```
919
+
920
+ Choose a date to see its price selected with it. Dates outside the current month have no price.
921
+
922
+ ## Range Limits
923
+
924
+ `minDays` and `maxDays` count both ends. A three-day range includes its start, the day between, and its end. A press that would break a limit keeps the start, so another end can be chosen. Until then, the dates that can't end the range are disabled.
925
+
926
+ A range cannot include an unavailable date unless `allowUnavailable` is set. That allows unavailable dates between the ends; they still cannot be chosen as an endpoint.
927
+
928
+ ```tsx title="range-limits.tsx"
929
+ "use client"
930
+
931
+ import {
932
+ Calendar,
933
+ CalendarDay,
934
+ CalendarGrid,
935
+ CalendarHeading,
936
+ CalendarNext,
937
+ CalendarPrevious,
938
+ CalendarWeekday,
939
+ CalendarWeekdays,
940
+ CalendarWeeks,
941
+ } from "@ui-sdk/react/calendar"
942
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
943
+
944
+ function Example() {
945
+ return (
946
+ <Calendar
947
+ mode="range"
948
+ minDays={3}
949
+ maxDays={8}
950
+ unavailable={{ from: "2026-10-17", to: "2026-10-18" }}
951
+ allowUnavailable
952
+ >
953
+ <div data-slot="row">
954
+ <CalendarPrevious data-variant="ghost">
955
+ <ChevronLeftIcon aria-hidden="true" />
956
+ </CalendarPrevious>
957
+ <CalendarHeading />
958
+ <CalendarNext data-variant="ghost">
959
+ <ChevronRightIcon aria-hidden="true" />
960
+ </CalendarNext>
961
+ </div>
962
+ <CalendarGrid>
963
+ <CalendarWeekdays>
964
+ {(index) => <CalendarWeekday index={index} />}
965
+ </CalendarWeekdays>
966
+ <CalendarWeeks>
967
+ {(cell) => <CalendarDay value={cell.date} />}
968
+ </CalendarWeeks>
969
+ </CalendarGrid>
970
+ </Calendar>
971
+ )
972
+ }
973
+
974
+ export { Example }
975
+ ```
976
+
977
+ In October 2026, choose October 15 then October 20. This example accepts 3–8 days and allows the range to span the unavailable weekend.
978
+
979
+ ## Range in Progress
980
+
981
+ The root's state has `anchor`, the start while an end is being picked, and `focused`, the date with the Tab stop. `onAnchorChange` and `onFocusedChange` report them before they change, to show the range being picked outside the calendar, and canceling either keeps things as they were. A day that takes focus because the months turned reports nothing.
982
+
983
+ ```tsx title="range-progress.tsx"
984
+ "use client"
985
+
986
+ import {
987
+ Calendar,
988
+ CalendarDay,
989
+ CalendarGrid,
990
+ CalendarHeading,
991
+ CalendarNext,
992
+ CalendarPrevious,
993
+ CalendarWeekday,
994
+ CalendarWeekdays,
995
+ CalendarWeeks,
996
+ } from "@ui-sdk/react/calendar"
997
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
998
+ import * as React from "react"
999
+ import { useLog } from "./log"
1000
+
1001
+ function Example() {
1002
+ const log = useLog()
1003
+ return (
1004
+ <div>
1005
+ <Calendar
1006
+ mode="range"
1007
+ onAnchorChange={(anchor) =>
1008
+ log(anchor ? `Started on ${anchor}` : "Range finished")
1009
+ }
1010
+ onFocusedChange={(focused) => log(`Focus on ${focused}`)}
1011
+ >
1012
+ <div data-slot="row">
1013
+ <CalendarPrevious data-variant="ghost">
1014
+ <ChevronLeftIcon aria-hidden="true" />
1015
+ </CalendarPrevious>
1016
+ <CalendarHeading />
1017
+ <CalendarNext data-variant="ghost">
1018
+ <ChevronRightIcon aria-hidden="true" />
1019
+ </CalendarNext>
1020
+ </div>
1021
+ <CalendarGrid>
1022
+ <CalendarWeekdays>
1023
+ {(index) => <CalendarWeekday index={index} />}
1024
+ </CalendarWeekdays>
1025
+ <CalendarWeeks>
1026
+ {(cell) => <CalendarDay value={cell.date} />}
1027
+ </CalendarWeeks>
1028
+ </CalendarGrid>
1029
+ </Calendar>
1030
+ </div>
1031
+ )
1032
+ }
1033
+
1034
+ export { Example }
1035
+ ```
1036
+
1037
+ Choose a start date, then move with the arrow keys. The console logs the start and each focused date until Enter picks the end.
1038
+
1039
+ ## Controlled
1040
+
1041
+ The selection and displayed month are separate. `value` uses the shape for the chosen mode; `month` names the first displayed month, such as `"2026-10"`.
1042
+
1043
+ Use `value` with `onValueChange` and `month` with `onMonthChange` to control them. Use `defaultValue` and `defaultMonth` for initial state. Change details include a reason; `details.cancel()` rejects the change. [State and Events](../state-and-events.md) covers the binding pattern, and the [reason tables](#reasons) list Calendar’s reasons.
1044
+
1045
+ ```tsx title="controlled.tsx"
1046
+ import {
1047
+ Calendar,
1048
+ CalendarDay,
1049
+ CalendarGrid,
1050
+ CalendarHeading,
1051
+ CalendarNext,
1052
+ CalendarPrevious,
1053
+ CalendarWeekday,
1054
+ CalendarWeekdays,
1055
+ CalendarWeeks,
1056
+ type CalendarValue,
1057
+ } from "@ui-sdk/react/calendar"
1058
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
1059
+ import * as React from "react"
1060
+ import { useLog } from "./log"
1061
+
1062
+ export function Example() {
1063
+ const [value, setValue] = React.useState<CalendarValue>("2026-10-16")
1064
+ const [month, setMonth] = React.useState("2026-10")
1065
+ const log = useLog()
1066
+ return (
1067
+ <div>
1068
+ <Calendar
1069
+ value={value}
1070
+ onValueChange={(next, details) => {
1071
+ setValue(next)
1072
+ log(`Selected ${String(next)} (${details.reason})`)
1073
+ }}
1074
+ month={month}
1075
+ onMonthChange={(next, details) => {
1076
+ setMonth(next)
1077
+ log(`Showing ${next} (${details.reason})`)
1078
+ }}
1079
+ >
1080
+ <div data-slot="row">
1081
+ <CalendarPrevious data-variant="ghost">
1082
+ <ChevronLeftIcon />
1083
+ </CalendarPrevious>
1084
+ <CalendarHeading />
1085
+ <CalendarNext data-variant="ghost">
1086
+ <ChevronRightIcon />
1087
+ </CalendarNext>
1088
+ </div>
1089
+ <CalendarGrid>
1090
+ <CalendarWeekdays>
1091
+ {(index) => <CalendarWeekday index={index} />}
1092
+ </CalendarWeekdays>
1093
+ <CalendarWeeks>
1094
+ {(cell) => <CalendarDay value={cell.date} />}
1095
+ </CalendarWeeks>
1096
+ </CalendarGrid>
1097
+ </Calendar>
1098
+ </div>
1099
+ )
1100
+ }
1101
+ ```
1102
+
1103
+ Choose a date or change the month. The console logs each change and its reason.
1104
+
1105
+ ## Today
1106
+
1107
+ Today gets `aria-current="date"` and `data-today`. When there is no selection or starting month, the calendar opens on today’s month. It reads today on the client; set `today` to pin a date explicitly.
1108
+
1109
+ `timeZone` determines which date is today. It does not convert the selected date into another time zone.
1110
+
1111
+ ```tsx title="time-zone.tsx"
1112
+ "use client"
1113
+
1114
+ import {
1115
+ Calendar,
1116
+ CalendarDay,
1117
+ CalendarGrid,
1118
+ CalendarHeading,
1119
+ CalendarNext,
1120
+ CalendarPrevious,
1121
+ CalendarWeekday,
1122
+ CalendarWeekdays,
1123
+ CalendarWeeks,
1124
+ } from "@ui-sdk/react/calendar"
1125
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
1126
+
1127
+ function Example() {
1128
+ return (
1129
+ <div>
1130
+ <Calendar timeZone="Pacific/Kiritimati">
1131
+ <div data-slot="row">
1132
+ <CalendarPrevious data-variant="ghost">
1133
+ <ChevronLeftIcon aria-hidden="true" />
1134
+ </CalendarPrevious>
1135
+ <CalendarHeading />
1136
+ <CalendarNext data-variant="ghost">
1137
+ <ChevronRightIcon aria-hidden="true" />
1138
+ </CalendarNext>
1139
+ </div>
1140
+ <CalendarGrid>
1141
+ <CalendarWeekdays>
1142
+ {(index) => <CalendarWeekday index={index} />}
1143
+ </CalendarWeekdays>
1144
+ <CalendarWeeks>
1145
+ {(cell) => <CalendarDay value={cell.date} />}
1146
+ </CalendarWeeks>
1147
+ </CalendarGrid>
1148
+ </Calendar>
1149
+ <p data-slot="hint">
1150
+ Today is marked as it is in Kiritimati, the first place to see each new
1151
+ day.
1152
+ </p>
1153
+ </div>
1154
+ )
1155
+ }
1156
+
1157
+ export { Example }
1158
+ ```
1159
+
1160
+ Find the marked date for today in Pacific/Kiritimati, which may differ from today in your time zone.
1161
+
1162
+ ## Driving It from Anywhere
1163
+
1164
+ A `createCalendarController()` instance can set the value, change months, and focus a date. Focusing a date in another month shows that month first. [Controllers](../controllers.md) covers setup and lifecycle.
1165
+
1166
+ ```tsx title="controller.tsx"
1167
+ "use client"
1168
+
1169
+ import { todayDate } from "@ui-sdk/core/date"
1170
+ import * as React from "react"
1171
+ import {
1172
+ Calendar,
1173
+ CalendarDay,
1174
+ CalendarGrid,
1175
+ CalendarHeading,
1176
+ CalendarNext,
1177
+ CalendarPrevious,
1178
+ CalendarWeekday,
1179
+ CalendarWeekdays,
1180
+ CalendarWeeks,
1181
+ createCalendarController,
1182
+ } from "@ui-sdk/react/calendar"
1183
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
1184
+
1185
+ function Example() {
1186
+ const [calendar] = React.useState(() => createCalendarController())
1187
+ const select = (date: string) => {
1188
+ calendar.setValue(date)
1189
+ calendar.focus(date)
1190
+ }
1191
+ return (
1192
+ <div data-slot="stack">
1193
+ <div data-slot="controls">
1194
+ <button type="button" onClick={() => select("2026-12-25")}>
1195
+ Go to Christmas
1196
+ </button>
1197
+ <button type="button" onClick={() => select(todayDate())}>
1198
+ Today
1199
+ </button>
1200
+ </div>
1201
+ <Calendar controller={calendar} defaultValue="2026-10-16" defaultMonth="2026-10">
1202
+ <div data-slot="row">
1203
+ <CalendarPrevious data-variant="ghost">
1204
+ <ChevronLeftIcon aria-hidden="true" />
1205
+ </CalendarPrevious>
1206
+ <CalendarHeading />
1207
+ <CalendarNext data-variant="ghost">
1208
+ <ChevronRightIcon aria-hidden="true" />
1209
+ </CalendarNext>
1210
+ </div>
1211
+ <CalendarGrid>
1212
+ <CalendarWeekdays>
1213
+ {(index) => <CalendarWeekday index={index} />}
1214
+ </CalendarWeekdays>
1215
+ <CalendarWeeks>
1216
+ {(cell) => <CalendarDay value={cell.date} />}
1217
+ </CalendarWeeks>
1218
+ </CalendarGrid>
1219
+ </Calendar>
1220
+ </div>
1221
+ )
1222
+ }
1223
+
1224
+ export { Example }
1225
+ ```
1226
+
1227
+ Press Go to Christmas to select December 25 and move focus there, or Today to jump back to today and select it.
1228
+
1229
+ ## Presets
1230
+
1231
+ Drive a range calendar from buttons for the ranges people pick most. Each preset sets the value through the [controller](#driving-it-from-anywhere) and moves focus to its first day, using the [date helpers](../core.md#dates) for the arithmetic.
1232
+
1233
+ ```tsx title="presets.tsx"
1234
+ "use client"
1235
+
1236
+ import { addDays, endOfMonth, startOfMonth } from "@ui-sdk/core/date"
1237
+ import * as React from "react"
1238
+ import {
1239
+ Calendar,
1240
+ CalendarDay,
1241
+ CalendarGrid,
1242
+ CalendarHeading,
1243
+ CalendarNext,
1244
+ CalendarPrevious,
1245
+ CalendarWeekday,
1246
+ CalendarWeekdays,
1247
+ CalendarWeeks,
1248
+ createCalendarController,
1249
+ } from "@ui-sdk/react/calendar"
1250
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
1251
+
1252
+ const today = "2026-10-16"
1253
+ const presets = [
1254
+ { label: "Last 7 Days", range: [addDays(today, -6), today] },
1255
+ { label: "This Month", range: [startOfMonth(today), endOfMonth(today)] },
1256
+ { label: "Next 30 Days", range: [today, addDays(today, 29)] },
1257
+ ] as const
1258
+
1259
+ function Example() {
1260
+ const [calendar] = React.useState(() => createCalendarController())
1261
+
1262
+ return (
1263
+ <div data-slot="stack">
1264
+ <div data-slot="controls">
1265
+ {presets.map((preset) => (
1266
+ <button
1267
+ key={preset.label}
1268
+ type="button"
1269
+ data-size="sm"
1270
+ onClick={() => {
1271
+ calendar.setValue([...preset.range])
1272
+ calendar.focus(preset.range[0])
1273
+ }}
1274
+ >
1275
+ {preset.label}
1276
+ </button>
1277
+ ))}
1278
+ </div>
1279
+ <Calendar mode="range" controller={calendar} today={today} defaultMonth="2026-10">
1280
+ <div data-slot="row">
1281
+ <CalendarPrevious data-variant="ghost">
1282
+ <ChevronLeftIcon aria-hidden="true" />
1283
+ </CalendarPrevious>
1284
+ <CalendarHeading />
1285
+ <CalendarNext data-variant="ghost">
1286
+ <ChevronRightIcon aria-hidden="true" />
1287
+ </CalendarNext>
1288
+ </div>
1289
+ <CalendarGrid>
1290
+ <CalendarWeekdays>
1291
+ {(index) => <CalendarWeekday index={index} />}
1292
+ </CalendarWeekdays>
1293
+ <CalendarWeeks>
1294
+ {(cell) => <CalendarDay value={cell.date} />}
1295
+ </CalendarWeeks>
1296
+ </CalendarGrid>
1297
+ </Calendar>
1298
+ </div>
1299
+ )
1300
+ }
1301
+
1302
+ export { Example }
1303
+ ```
1304
+
1305
+ Choose Last 7 Days, This Month or Next 30 Days. The range is selected and the calendar shows its start.
1306
+
1307
+ ## Custom Rendering
1308
+
1309
+ The grid’s state exposes its month, label, weekdays, and weeks when you need to write the table yourself. Preserve empty cells marked `hidden` so dates shown by another month do not appear twice. [Parts and Composition](../parts-and-composition.md) covers changing a part’s element without losing its behavior.
1310
+
1311
+ ```tsx title="custom-grid.tsx"
1312
+ import {
1313
+ Calendar,
1314
+ CalendarDay,
1315
+ CalendarGrid,
1316
+ CalendarHeading,
1317
+ CalendarNext,
1318
+ CalendarPrevious,
1319
+ CalendarWeekday,
1320
+ } from "@ui-sdk/react/calendar"
1321
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
1322
+
1323
+ function isoWeek(date: string) {
1324
+ const day = new Date(`${date}T00:00:00Z`)
1325
+ day.setUTCDate(day.getUTCDate() + 3 - ((day.getUTCDay() + 6) % 7))
1326
+ const firstThursday = new Date(Date.UTC(day.getUTCFullYear(), 0, 4))
1327
+ const days = (day.getTime() - firstThursday.getTime()) / 86400000
1328
+ return 1 + Math.round((days - 3 + ((firstThursday.getUTCDay() + 6) % 7)) / 7)
1329
+ }
1330
+
1331
+ export function Example() {
1332
+ return (
1333
+ <Calendar defaultValue="2026-10-16" weekStartsOn={1}>
1334
+ <div data-slot="row">
1335
+ <CalendarPrevious
1336
+ data-variant="ghost"
1337
+ render={(props, step) => (
1338
+ <button {...props} title={`Show ${step.month}`} />
1339
+ )}
1340
+ >
1341
+ <ChevronLeftIcon />
1342
+ </CalendarPrevious>
1343
+ <CalendarHeading>{(heading) => heading.label}</CalendarHeading>
1344
+ <CalendarNext data-variant="ghost">
1345
+ <ChevronRightIcon />
1346
+ </CalendarNext>
1347
+ </div>
1348
+ <CalendarGrid>
1349
+ {(grid) => (
1350
+ <>
1351
+ <thead>
1352
+ <tr>
1353
+ <th scope="col">
1354
+ <abbr title="Week">Wk</abbr>
1355
+ </th>
1356
+ {grid.weekdays.map((weekday, index) => (
1357
+ <CalendarWeekday key={weekday} index={index} />
1358
+ ))}
1359
+ </tr>
1360
+ </thead>
1361
+ <tbody>
1362
+ {grid.weeks.map((week) => (
1363
+ <tr key={week[0]!.date}>
1364
+ <th scope="row" data-slot="hint">
1365
+ {isoWeek(week[0]!.date)}
1366
+ </th>
1367
+ {week.map((cell) =>
1368
+ cell.hidden ? (
1369
+ <td key={cell.date} />
1370
+ ) : (
1371
+ <CalendarDay key={cell.date} value={cell.date} />
1372
+ )
1373
+ )}
1374
+ </tr>
1375
+ ))}
1376
+ </tbody>
1377
+ </>
1378
+ )}
1379
+ </CalendarGrid>
1380
+ </Calendar>
1381
+ )
1382
+ }
1383
+ ```
1384
+
1385
+ The table is your own markup, built from the grid's state. Navigate and select as usual.
1386
+
1387
+ ## Styling
1388
+
1389
+ Use `data-selected`, `data-today`, `data-outside`, `data-unavailable`, and `data-disabled` to style dates. A range also exposes its start, middle, end, and unfinished preview. Navigation buttons also get `data-disabled` when they reach the bounds.
1390
+
1391
+ Each part has a `data-slot`, such as `calendar-day`, and its state attributes are listed under [Data Attributes](#data-attributes).
1392
+
1393
+ ## Data Attributes
1394
+
1395
+ ### Calendar
1396
+ `[data-slot="calendar"]`
1397
+
1398
+ - `data-mode` (`single`, `multiple`, `range`): How the calendar selects.
1399
+ - `data-readonly`: Present when dates can be focused but not picked.
1400
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1401
+
1402
+ ### CalendarPrevious
1403
+ `[data-slot="calendar-previous"]`
1404
+
1405
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1406
+
1407
+ ### CalendarNext
1408
+ `[data-slot="calendar-next"]`
1409
+
1410
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1411
+
1412
+ ### CalendarMonthSelect
1413
+ `[data-slot="calendar-month-select"]`
1414
+
1415
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1416
+
1417
+ ### CalendarYearSelect
1418
+ `[data-slot="calendar-year-select"]`
1419
+
1420
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1421
+
1422
+ ### CalendarGrid
1423
+ `[data-slot="calendar-grid"]`
1424
+
1425
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1426
+
1427
+ ### CalendarDay
1428
+ `[data-slot="calendar-day"]`
1429
+
1430
+ - `data-value` (`2026-10-01`, `2026-10-14`, `2026-10-16`, `2026-10-18`, `2026-10-24`, `2026-09-30`): A day's ISO date.
1431
+ - `data-selected`: Present on selected days. In a range, every day from start to end.
1432
+ - `data-today`: Present on today, beside `aria-current="date"`.
1433
+ - `data-disabled`: Present on the root, grids and selects when the calendar is disabled, on a day that can't be picked, and on Previous or Next at `min` or `max`.
1434
+ - `data-unavailable`: Present on a day `unavailable` names. It stays focusable.
1435
+ - `data-outside`: Present on a day of the month before or after its grid's.
1436
+ - `data-range-start`: Present on the day a range starts, including one being picked.
1437
+ - `data-range-middle`: Present on the days inside a range, between its ends.
1438
+ - `data-range-end`: Present on the day a range ends, including one being picked.
1439
+ - `data-preview`: Present on the days of a range being picked, from its start to the day under the pointer or focus.
1440
+
1441
+ ## API Reference
1442
+
1443
+ Props and callbacks are the same as below, as React props.
1444
+
1445
+ ### Calendar
1446
+
1447
+ - `mode?` (`CalendarMode`): How many dates it selects: one, any number, or a range from a start to an end.
1448
+ - `value?` (`CalendarValue`): The selected value: an ISO date for `"single"`, a list for `"multiple"`, `[start, end]` for `"range"`, or `null`. Pass it to control the calendar.
1449
+ - `defaultValue?` (`CalendarValue`): The value it starts with, when uncontrolled.
1450
+ - `onValueChange?` (`((value: CalendarValue, details: ChangeDetails<CalendarValueChangeReason>) => void)`): Runs when a date is pressed (`"item-press"`), with Enter or Space too, or a controller sets the value (`"imperative"`). A range changes once both ends are picked. `details.cancel()` keeps the value.
1451
+ - `month?` (`string`): The first month shown, like `"2026-10"`. Pass it to control the calendar.
1452
+ - `defaultMonth?` (`string`): The first month it shows, when uncontrolled. Defaults to the selected date's month, else today's.
1453
+ - `onMonthChange?` (`((month: ISOMonth, details: ChangeDetails<CalendarMonthChangeReason>) => void)`): Runs when the months shown want to change: Previous or Next, a key moving focus to another month, a press on a day of another month, or a controller.
1454
+ - `min?` (`string`): The earliest date that can be picked. Keys stop there, and Previous stops at its month.
1455
+ - `max?` (`string`): The latest date that can be picked.
1456
+ - `unavailable?` (`DateMatchers`): Dates that can't be picked, like booked days, as data: ISO dates, `{ from, to }`, `{ weekday: [0, 6] }` for weekends, `{ before }`, `{ after }`, or a function. They stay focusable, so keyboard users hear them.
1457
+ - `disabled?` (`boolean`): Whether nothing can be picked or focused.
1458
+ - `readOnly?` (`boolean`): Whether dates can be focused but not picked.
1459
+ - `deselectable?` (`boolean`): Whether pressing the selected date again clears it, in `"single"` mode.
1460
+ - `onFocusedChange?` (`((date: ISODate, details: ChangeDetails<CalendarFocusedChangeReason>) => void)`): Runs before keys, a press or `focus()` move focus to another day. Canceling keeps focus where it was.
1461
+ - `onAnchorChange?` (`((anchor: ISODate | null, details: ChangeDetails<CalendarAnchorChangeReason>) => void)`): Runs before a press starts a range, or ends it or Escape drops it, with `null`. Canceling keeps the start as it was.
1462
+ - `months?` (`number`): How many months show side by side, each in its own grid.
1463
+ - `pageBy?` (`"month" | "page"`): Whether Previous, Next and keys turn one month, or all the months shown.
1464
+ - `locale?` (`string`): The language of the names and labels. Defaults to the page's `lang`, then the browser's.
1465
+ - `weekStartsOn?` (`number`): The first day of the week, 0 for Sunday. Defaults to the locale's.
1466
+ - `weekdayFormat?` (`"long" | "narrow" | "short"`): How weekday headers are written.
1467
+ - `monthFormat?` (`"long" | "narrow" | "short"`): How month names are written, in the heading and the month select.
1468
+ - `fixedWeeks?` (`boolean`): Whether every month shows six weeks, so the calendar doesn't change height.
1469
+ - `showOutsideDays?` (`boolean`): Whether the days of the months before and after show at the edges.
1470
+ - `today?` (`string`): Today's date, for `aria-current` and the starting month. Defaults to today in `timeZone`, read on the client.
1471
+ - `timeZone?` (`string`): The time zone that says what day today is, like `"America/New_York"`. Defaults to the browser's.
1472
+ - `minDays?` (`number`): The fewest days a range can span, counting both ends.
1473
+ - `maxDays?` (`number`): The most days a range can span, counting both ends.
1474
+ - `allowUnavailable?` (`boolean`): Whether a range may hold unavailable dates, like a stay over a booked night.
1475
+ - `controller?` (`object`): Drives it from anywhere. Create one with `createCalendarController()`.
1476
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
1477
+
1478
+ ### CalendarPrevious
1479
+
1480
+ Shows the previous month. Renders a `button` that is disabled at `min`.
1481
+
1482
+ ### CalendarHeading
1483
+
1484
+ Names the months shown, like "October 2026". Renders an `h2` the grid is labelled by, and screen readers hear it change.
1485
+
1486
+ ### CalendarNext
1487
+
1488
+ Shows the next month. Renders a `button` that is disabled at `max`.
1489
+
1490
+ ### CalendarMonthSelect
1491
+
1492
+ A native `select` of the months, in the locale, that changes the first month shown.
1493
+
1494
+ ### CalendarYearSelect
1495
+
1496
+ A native `select` of the years from `min` to `max`, or 10 either side of the year shown.
1497
+
1498
+ ### CalendarGrid
1499
+
1500
+ - `offset?` (`number`): Which of the months shown it is, from 0.
1501
+
1502
+ ### CalendarWeekdays
1503
+
1504
+ Renders the header row. Its children are a function that receives each weekday's index.
1505
+
1506
+ ### CalendarWeekday
1507
+
1508
+ - `index` (`number`): The column, from 0.
1509
+
1510
+ ### CalendarWeeks
1511
+
1512
+ Renders the week rows. Its children are a function that receives each cell, with its `date`.
1513
+
1514
+ ### CalendarDay
1515
+
1516
+ - `value` (`string`): Its ISO date.
1517
+ - `offset?` (`number`): The offset of the grid it's in.
1518
+
1519
+ ### State
1520
+
1521
+ What render functions, state-based class names and children functions receive, per part.
1522
+
1523
+ `Calendar`:
1524
+
1525
+ - `value` (`CalendarValue`): The selected value.
1526
+ - `month` (`string`): The first month shown.
1527
+ - `mode` (`CalendarMode`): How it selects.
1528
+ - `disabled` (`boolean`): Whether nothing can be picked or focused.
1529
+ - `readOnly` (`boolean`): Whether dates can be focused but not picked.
1530
+ - `focused` (`string | null`): The date with the tab stop, `null` until days render in the browser.
1531
+ - `anchor` (`string | null`): A range's start while its end is being picked, else `null`.
1532
+
1533
+ `CalendarHeading`:
1534
+
1535
+ - `month` (`string`): The first month shown, to format the heading yourself.
1536
+ - `label` (`string`): The months shown in `monthFormat`, like "October 2026", or "October – November 2026".
1537
+
1538
+ `CalendarMonthSelect` and `CalendarYearSelect`:
1539
+
1540
+ - `value` (`number`): The first month shown's month, 1 to 12, or its year.
1541
+ - `options` (`CalendarSelectOption[]`): Every month, or the years from `min` to `max` (10 either side of the year shown without them).
1542
+ - `disabled` (`boolean`): Whether the calendar's `disabled` option is on. Inside a Date Picker, a disabled `<fieldset>` around the picker counts too.
1543
+
1544
+ `CalendarPrevious` and `CalendarNext`:
1545
+
1546
+ - `month` (`string`): The first month it shows.
1547
+ - `disabled` (`boolean`): Whether it can't go further, past `min` or `max`.
1548
+
1549
+ `CalendarGrid`:
1550
+
1551
+ - `month` (`string`): The month it shows: the first month shown, plus its `offset`.
1552
+ - `label` (`string`): The month's name and year in `monthFormat`, like "October 2026".
1553
+ - `weekdays` (`number[]`): The weekday of each column, 0 for Sunday, in the order they show.
1554
+ - `weeks` (`CalendarGridCell[][]`): The weeks, each seven cells. Render a day for each cell that isn't hidden.
1555
+
1556
+ `CalendarWeekday`:
1557
+
1558
+ - `weekday` (`number`): The weekday, 0 for Sunday.
1559
+ - `label` (`string`): Its name, in `weekdayFormat`.
1560
+ - `name` (`string`): Its full name, which screen readers hear.
1561
+
1562
+ `CalendarDay`:
1563
+
1564
+ - `date` (`string`): Its ISO date.
1565
+ - `label` (`string`): The day of the month in the locale's digits, like "16".
1566
+ - `selected` (`boolean`): Whether it's selected. In a range, every date from start to end is.
1567
+ - `today` (`boolean`): Whether it's the `today` option's date, or else today in `timeZone`, read once the calendar runs in the browser.
1568
+ - `outside` (`boolean`): Whether it belongs to the month before or after its grid's.
1569
+ - `disabled` (`boolean`): Whether it can't be picked: outside `min` and `max`, unavailable, unable to end the range being picked, or the calendar is disabled.
1570
+ - `unavailable` (`boolean`): Whether `unavailable` names it.
1571
+ - `rangeStart` (`boolean`): Whether a range starts here, including one being picked.
1572
+ - `rangeEnd` (`boolean`): Whether a range ends here, including one being picked.
1573
+ - `inRange` (`boolean`): Whether it's inside a range, ends included, including one being picked.
1574
+
1575
+ ### Reasons
1576
+
1577
+ `details.reason` says why the value changed:
1578
+
1579
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1580
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1581
+
1582
+ And why the month changed:
1583
+
1584
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1585
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1586
+ - `previous-press` (`MouseEvent | KeyboardEvent`): A pagination's or a carousel's Previous part was pressed.
1587
+ - `next-press` (`MouseEvent | KeyboardEvent`): A pagination's or a carousel's Next part was pressed.
1588
+ - `list-navigation` (`KeyboardEvent`): Arrow, Home or End keys moved the selection, typing picked an item, or Ctrl or ⌘ with A selected every item of a listbox.
1589
+ - `select-change`
1590
+
1591
+ Why focus moves to another day:
1592
+
1593
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1594
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1595
+ - `list-navigation` (`KeyboardEvent`): Arrow, Home or End keys moved the selection, typing picked an item, or Ctrl or ⌘ with A selected every item of a listbox.
1596
+ - `focus-in` (`FocusEvent`): Keyboard focus moved into the component, which stops a rotating carousel, as the carousel pattern asks, or onto a canvas item, which brought it into view, or onto a calendar's day another way, like a screen reader's.
1597
+
1598
+ And why a range's start changed:
1599
+
1600
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
1601
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1602
+
1603
+ ### Controller
1604
+
1605
+ Create one with `createCalendarController()` and pass it as `controller`. Every write method takes an optional `{ reason, event }` and returns `false` when the change is canceled, there's nowhere to go, or the calendar is disabled or read-only.
1606
+
1607
+ - `getValue()` (`() => CalendarValue`): The selected value: an ISO date, a list of them, or a `[start, end]` range.
1608
+ - `setValue(value, options?)` (`(value: CalendarValue, options?: CalendarChangeOptions<CalendarValueChangeReason> | undefined) => boolean`): Selects a value. Returns false when canceled, unchanged, disabled, read-only, or holding a date people can't pick, like one past `max`.
1609
+ - `getMonth()` (`() => string`): The first month shown, like `"2026-10"`.
1610
+ - `setMonth(month, options?)` (`(month: string, options?: CalendarChangeOptions<CalendarMonthChangeReason> | undefined) => boolean`): Shows a month first. Returns false when canceled or unchanged.
1611
+ - `previous(options?)` (`(options?: CalendarChangeOptions<CalendarMonthChangeReason> | undefined) => boolean`): Shows the months before, as the Previous part does.
1612
+ - `next(options?)` (`(options?: CalendarChangeOptions<CalendarMonthChangeReason> | undefined) => boolean`): Shows the months after, as the Next part does.
1613
+ - `focus(date?)` (`(date?: string | undefined) => void`): Focuses a date, turning the months to show it, or the date with the tab stop.
1614
+
1615
+ ### Events
1616
+
1617
+ Callbacks get the new value first, then the details.
1618
+
1619
+ | Prop | On | Receives |
1620
+ | ----------------- | ---------- | -------------------------------------------------------------------------------------- |
1621
+ | `onValueChange` | `Calendar` | `(value, details)`: the new value, and the [reason](#reasons) |
1622
+ | `onMonthChange` | `Calendar` | `(month, details)`: the new first month, and the [reason](#reasons) |
1623
+ | `onFocusedChange` | `Calendar` | `(date, details)`: the day focus moves to, and the [reason](#reasons) |
1624
+ | `onAnchorChange` | `Calendar` | `(date, details)`: a range's start, or `null` once it ends, and the [reason](#reasons) |
1625
+
1626
+ ## Accessibility
1627
+
1628
+ It follows the grid of the [WAI-ARIA date picker dialog](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/): each month is a `grid` named by its month, weekday headers are `columnheader`s named by their full names, and each day is a focusable `gridcell` named by its full date, like "Friday, October 16, 2026", with `aria-selected`, `aria-disabled` and `aria-current="date"`. A grid that selects several dates or a range is `aria-multiselectable`. Every line below is an automated test.
1629
+
1630
+ ### Keyboard
1631
+
1632
+ The grid has one Tab stop: the selected date when visible, otherwise today, otherwise the first available date. Moving into another month shows it and then focuses the date.
1633
+
1634
+ | Key | Action |
1635
+ | ------------------------------- | ----------------------------------------------- |
1636
+ | Left / Right Arrow | Move one day, following the page’s direction. |
1637
+ | Up / Down Arrow | Move one week. |
1638
+ | Home / End | Move to the first or last day of the week. |
1639
+ | Page Up / Page Down | Move one month, keeping the day where possible. |
1640
+ | Shift+Page Up / Shift+Page Down | Move one year. |
1641
+ | Enter / Space | Select the focused date. |
1642
+ | Escape | Cancel an unfinished range. |
1643
+
1644
+ ### Tested Behavior
1645
+
1646
+ - The calendar shows a month as a grid of days under weekday headers.
1647
+ - The selected date holds the tab stop, else today.
1648
+ - Tab leaves the grid after one stop.
1649
+ - Arrow keys move focus by day and week.
1650
+ - Moving past the month's edge shows the next month and focuses the day there.
1651
+ - Page Up and Page Down move by month, and with Shift by year.
1652
+ - The day of the month stays the same, or the month's last, when moving by month.
1653
+ - Home and End go to the first and last day of the week.
1654
+ - The week starts on the locale's first day.
1655
+ - Pressing a day selects it.
1656
+ - Enter on a focused day selects it.
1657
+ - Space on a focused day selects it.
1658
+ - Previous and Next show the month before and after, and the heading announces it.
1659
+ - Min and max stop keys there, and Previous and Next at their months.
1660
+ - Unavailable dates can be focused but not selected.
1661
+ - In multiple mode, presses toggle dates.
1662
+ - In range mode, two presses pick a range, previewed in between.
1663
+ - In range mode, keys preview the end and Escape drops the start.
1664
+ - A range keeps to its fewest and most days, and keeps its start.
1665
+ - Two months show side by side, and focus moves between them without turning.
1666
+ - Pressing a day of the next month selects it and shows its month.
1667
+ - Pressing another month's day before min keeps the month shown.
1668
+ - Pressing another month's day before min leaves focus on the day that had it.
1669
+ - A controlled calendar shows what the app passes.
1670
+ - A controller turns to a date and focuses it.
1671
+ - A disabled calendar has no tab stop and selects nothing.
1672
+ - A read-only calendar moves focus but selects nothing.
1673
+
1674
+ **Month and year selects**
1675
+
1676
+ - They show the first month shown and turn the calendar, with the select-change reason.
1677
+ - Years run from min to max, and months past them are disabled.
1678
+ - They follow the page's language.
1679
+
1680
+ Runs in React, Vue and web components.
1681
+
1682
+ Beyond the baseline:
1683
+
1684
+ - Keys pressed without waiting still land on the right day.
1685
+ - A day of next month takes focus even when its month renders after the key.
1686
+
1687
+ Runs in React, Vue and web components.