@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,1014 @@
1
+ # Tabs
2
+
3
+ Switch between related panels with one tab selected at a time.
4
+
5
+ Use Tabs when several views share the same space, such as settings sections or a preview and its source. Each tab opens the panel with the same value.
6
+
7
+ <ComponentExample
8
+ name="tabs/basic"
9
+ inspect
10
+ caption="Choose Password to show its panel. Use the left and right arrow keys to move between the tabs."
11
+ />
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @ui-sdk/react @ui-sdk/core
17
+ ```
18
+
19
+ ## Composition
20
+
21
+ Use the following composition to build a `Tabs`:
22
+
23
+ ```text
24
+ Tabs
25
+ ├── TabsList
26
+ │ ├── TabsTab
27
+ │ └── TabsTab
28
+ ├── TabsPanel
29
+ └── TabsPanel
30
+ ```
31
+
32
+ Give each tab and its panel the same unique `value`. Give the list an accessible name. Set `defaultValue` to choose the initial tab; otherwise, the first enabled tab is selected.
33
+
34
+ ## Usage
35
+
36
+ Import the parts and put them together:
37
+
38
+ ```tsx
39
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
40
+
41
+ function Example() {
42
+ return (
43
+ <Tabs defaultValue="account">
44
+ <TabsList aria-label="Settings">
45
+ <TabsTab value="account">Account</TabsTab>
46
+ <TabsTab value="password">Password</TabsTab>
47
+ </TabsList>
48
+ <TabsPanel value="account">Manage your profile.</TabsPanel>
49
+ <TabsPanel value="password">Choose a new password.</TabsPanel>
50
+ </Tabs>
51
+ )
52
+ }
53
+
54
+ export { Example }
55
+ ```
56
+
57
+ ## Build Your Own
58
+
59
+ `@ui-sdk/react/tabs` comes with ready-made Tabs. If you'd like to build your own, with your own names, start from the `tabs` primitive in `@ui-sdk/core`:
60
+
61
+ ```ts title="segments.ts"
62
+ "use client"
63
+
64
+ import { tabs } from "@ui-sdk/core/tabs"
65
+ import { createParts } from "@ui-sdk/react/primitive"
66
+
67
+ const {
68
+ Root: Segments,
69
+ List: SegmentList,
70
+ Tab: Segment,
71
+ Panel: SegmentPanel,
72
+ } = createParts(tabs, { root: "div", list: "div", tab: "button", panel: "div" })
73
+
74
+ export { Segment, SegmentList, SegmentPanel, Segments }
75
+ ```
76
+
77
+ ```tsx
78
+ <Segments defaultValue="day">
79
+ <SegmentList aria-label="Range">
80
+ <Segment value="day">Day</Segment>
81
+ <Segment value="week">Week</Segment>
82
+ </SegmentList>
83
+ <SegmentPanel value="day">128 visitors today.</SegmentPanel>
84
+ <SegmentPanel value="week">1,024 visitors this week.</SegmentPanel>
85
+ </Segments>
86
+ ```
87
+
88
+ Add `"tab-icon": "span"` and `indicator: "span"` to the elements to get the `TabIcon` and `Indicator` parts too. Each part keeps the behavior, state and data attributes of its ready-made counterpart. See [Rendering](../rendering.md) and [Custom Parts](../custom-parts.md) for more.
89
+
90
+ ## Vertical
91
+
92
+ Set `orientation="vertical"` to use Up and Down Arrow instead. Style the list as a column beside the panels to match.
93
+
94
+ ```tsx title="vertical.tsx"
95
+ "use client"
96
+
97
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
98
+
99
+ function Example() {
100
+ return (
101
+ <Tabs defaultValue="general" orientation="vertical">
102
+ <TabsList aria-label="Preferences">
103
+ <TabsTab value="general">General</TabsTab>
104
+ <TabsTab value="security">Security</TabsTab>
105
+ <TabsTab value="integrations">Integrations</TabsTab>
106
+ </TabsList>
107
+ <TabsPanel value="general">
108
+ Choose your language, time zone and the page you start on.
109
+ </TabsPanel>
110
+ <TabsPanel value="security">
111
+ Manage passkeys, signed-in sessions and recovery codes.
112
+ </TabsPanel>
113
+ <TabsPanel value="integrations">
114
+ Connect your calendar and chat apps to get reminders.
115
+ </TabsPanel>
116
+ </Tabs>
117
+ )
118
+ }
119
+
120
+ export { Example }
121
+ ```
122
+
123
+ Focus General, then press Down Arrow to choose Security. Up Arrow moves back through the vertical list.
124
+
125
+ ## Disabled
126
+
127
+ Add `disabled` to a tab to prevent selection. Arrow keys can still focus it so people can discover it.
128
+
129
+ ```tsx title="disabled.tsx"
130
+ "use client"
131
+
132
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
133
+
134
+ function Example() {
135
+ return (
136
+ <Tabs defaultValue="overview">
137
+ <TabsList aria-label="Dashboard">
138
+ <TabsTab value="overview">Overview</TabsTab>
139
+ <TabsTab value="analytics">Analytics</TabsTab>
140
+ <TabsTab value="reports" disabled>
141
+ Reports
142
+ </TabsTab>
143
+ </TabsList>
144
+ <TabsPanel value="overview">
145
+ Revenue, visitors and sign-ups for the last 30 days.
146
+ </TabsPanel>
147
+ <TabsPanel value="analytics">
148
+ Where your visitors come from and the pages they read most.
149
+ </TabsPanel>
150
+ <TabsPanel value="reports">
151
+ Monthly reports are available on the Pro plan.
152
+ </TabsPanel>
153
+ </Tabs>
154
+ )
155
+ }
156
+
157
+ export { Example }
158
+ ```
159
+
160
+ Use the arrow keys to reach Reports. It can receive focus, but pressing it leaves the current panel selected.
161
+
162
+ ## Icons
163
+
164
+ Put decorative icons in `TabsTabIcon` so they stay out of the tab’s accessible name. Add `mirror` to directional icons, such as Reply, to flip them in right-to-left text. An icon-only tab still needs an `aria-label`.
165
+
166
+ ```tsx title="icons.tsx"
167
+ "use client"
168
+
169
+ import {
170
+ Tabs,
171
+ TabsList,
172
+ TabsPanel,
173
+ TabsTab,
174
+ TabsTabIcon,
175
+ } from "@ui-sdk/react/tabs"
176
+ import { ArchiveIcon, MailIcon, ReplyIcon } from "lucide-react"
177
+
178
+ function Example() {
179
+ return (
180
+ <Tabs defaultValue="inbox">
181
+ <TabsList aria-label="Mail">
182
+ <TabsTab value="inbox">
183
+ <TabsTabIcon>
184
+ <MailIcon />
185
+ </TabsTabIcon>
186
+ Inbox
187
+ </TabsTab>
188
+ <TabsTab value="replies">
189
+ <TabsTabIcon mirror>
190
+ <ReplyIcon />
191
+ </TabsTabIcon>
192
+ Replies
193
+ </TabsTab>
194
+ <TabsTab value="archive">
195
+ <TabsTabIcon>
196
+ <ArchiveIcon />
197
+ </TabsTabIcon>
198
+ Archive
199
+ </TabsTab>
200
+ </TabsList>
201
+ <TabsPanel value="inbox">
202
+ 3 new messages from Inès Moreau and Kofi Mensah.
203
+ </TabsPanel>
204
+ <TabsPanel value="replies">
205
+ Wren Takahashi replied to your message about the launch.
206
+ </TabsPanel>
207
+ <TabsPanel value="archive">
208
+ Messages you archived stay here and in search.
209
+ </TabsPanel>
210
+ </Tabs>
211
+ )
212
+ }
213
+
214
+ export { Example }
215
+ ```
216
+
217
+ Choose Replies. Its directional icon mirrors when the surrounding page uses right-to-left text.
218
+
219
+ ## Manual Activation
220
+
221
+ Set `activation="manual"` when opening a panel takes time, such as a view that fetches data. Arrow keys move focus; Enter or Space selects the focused tab.
222
+
223
+ ```tsx
224
+ <Tabs activation="manual" />
225
+ ```
226
+
227
+ A panel becomes a tab stop only when it has no focusable content. A panel with a field lets Tab go straight to the field.
228
+
229
+ ```tsx title="manual.tsx"
230
+ "use client"
231
+
232
+ import { Field, FieldLabel } from "@ui-sdk/react/field"
233
+ import { Input } from "@ui-sdk/react/input"
234
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
235
+
236
+ function Example() {
237
+ return (
238
+ <Tabs defaultValue="preview" activation="manual">
239
+ <TabsList aria-label="Snippet">
240
+ <TabsTab value="preview">Preview</TabsTab>
241
+ <TabsTab value="code">Code</TabsTab>
242
+ </TabsList>
243
+ <TabsPanel value="preview">
244
+ Welcome back, Hollis. You have 3 unread messages.
245
+ </TabsPanel>
246
+ <TabsPanel value="code">
247
+ <Field>
248
+ <FieldLabel>Source</FieldLabel>
249
+ <Input defaultValue='<Welcome name="Hollis" unread={3} />' />
250
+ </Field>
251
+ </TabsPanel>
252
+ </Tabs>
253
+ )
254
+ }
255
+
256
+ export { Example }
257
+ ```
258
+
259
+ Focus Preview, then press Right Arrow. Code receives focus; press Enter or Space to show its panel. Tab then moves into the Source field.
260
+
261
+ ## Loop
262
+
263
+ Arrow keys normally wrap around at either end. Set `loop={false}` to stop there instead.
264
+
265
+ ```tsx title="loop.tsx"
266
+ "use client"
267
+
268
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
269
+
270
+ const ranges = [
271
+ {
272
+ value: "day",
273
+ label: "Day",
274
+ content: "128 visitors today, up 12% from yesterday.",
275
+ },
276
+ {
277
+ value: "week",
278
+ label: "Week",
279
+ content: "1,024 visitors this week, up 8% from last week.",
280
+ },
281
+ {
282
+ value: "month",
283
+ label: "Month",
284
+ content: "4,210 visitors this month, down 3% from last month.",
285
+ },
286
+ {
287
+ value: "year",
288
+ label: "Year",
289
+ content: "48,930 visitors this year, up 21% from last year.",
290
+ },
291
+ ]
292
+
293
+ function Example() {
294
+ return (
295
+ <Tabs defaultValue="day" loop={false}>
296
+ <TabsList aria-label="Range">
297
+ {ranges.map((range) => (
298
+ <TabsTab key={range.value} value={range.value}>
299
+ {range.label}
300
+ </TabsTab>
301
+ ))}
302
+ </TabsList>
303
+ {ranges.map((range) => (
304
+ <TabsPanel key={range.value} value={range.value}>
305
+ {range.content}
306
+ </TabsPanel>
307
+ ))}
308
+ </Tabs>
309
+ )
310
+ }
311
+
312
+ export { Example }
313
+ ```
314
+
315
+ Focus Year and press Right Arrow. Focus stays at the end because looping is off.
316
+
317
+ ## Indicator
318
+
319
+ `TabsIndicator` measures the selected tab. Position it inside a relative tab list and use its [CSS variables](#styling-tabsindicator) to make a marker that follows the selection. It measures again when a tab or the list changes size.
320
+
321
+ ```css
322
+ [data-slot="tabs-list"] {
323
+ position: relative;
324
+ }
325
+
326
+ [data-slot="tabs-indicator"] {
327
+ position: absolute;
328
+ top: var(--active-tab-top);
329
+ left: var(--active-tab-left);
330
+ width: var(--active-tab-width);
331
+ height: var(--active-tab-height);
332
+ transition-property: top, left, width, height;
333
+ transition-duration: 200ms;
334
+
335
+ &[data-activation-direction="none"] {
336
+ transition: none;
337
+ }
338
+ }
339
+ ```
340
+
341
+ Add transitions for the properties you animate. Skip them while `data-activation-direction="none"` to avoid animating the first placement.
342
+
343
+ ```tsx title="indicator.tsx"
344
+ "use client"
345
+
346
+ import {
347
+ Tabs,
348
+ TabsIndicator,
349
+ TabsList,
350
+ TabsPanel,
351
+ TabsTab,
352
+ } from "@ui-sdk/react/tabs"
353
+ import * as React from "react"
354
+
355
+ const orientations = [
356
+ { value: "horizontal", label: "Horizontal" },
357
+ { value: "vertical", label: "Vertical" },
358
+ ] as const
359
+
360
+ function Example() {
361
+ const [orientation, setOrientation] = React.useState<
362
+ "horizontal" | "vertical"
363
+ >("horizontal")
364
+
365
+ return (
366
+ <div>
367
+ <div data-slot="controls" role="group" aria-label="Orientation">
368
+ {orientations.map((option) => (
369
+ <button
370
+ key={option.value}
371
+ type="button"
372
+ data-size="sm"
373
+ aria-pressed={orientation === option.value}
374
+ onClick={() => setOrientation(option.value)}
375
+ >
376
+ {option.label}
377
+ </button>
378
+ ))}
379
+ </div>
380
+ <Tabs defaultValue="music" orientation={orientation}>
381
+ <TabsList aria-label="Library">
382
+ <TabsTab value="music">Music</TabsTab>
383
+ <TabsTab value="podcasts">Podcasts</TabsTab>
384
+ <TabsTab value="audiobooks">Audiobooks</TabsTab>
385
+ <TabsIndicator />
386
+ </TabsList>
387
+ <TabsPanel value="music">
388
+ 312 songs in 24 albums, synced to this device.
389
+ </TabsPanel>
390
+ <TabsPanel value="podcasts">
391
+ 8 shows you follow, with 3 new episodes.
392
+ </TabsPanel>
393
+ <TabsPanel value="audiobooks">
394
+ 2 books in progress, 6 hours left in total.
395
+ </TabsPanel>
396
+ </Tabs>
397
+ </div>
398
+ )
399
+ }
400
+
401
+ export { Example }
402
+ ```
403
+
404
+ Choose Podcasts, then choose Vertical. The same indicator measures and follows the selected tab in either layout.
405
+
406
+ ## Keep Mounted
407
+
408
+ Panels normally unmount when another tab is selected. Add `keepMounted` to a panel to keep its content hidden in the page, preserving local state such as a draft.
409
+
410
+ ```tsx title="keep-mounted.tsx"
411
+ "use client"
412
+
413
+ import { Field, FieldLabel } from "@ui-sdk/react/field"
414
+ import { Textarea } from "@ui-sdk/react/textarea"
415
+ import {
416
+ Tabs,
417
+ TabsIndicator,
418
+ TabsList,
419
+ TabsPanel,
420
+ TabsTab,
421
+ } from "@ui-sdk/react/tabs"
422
+
423
+ function Example() {
424
+ return (
425
+ <Tabs defaultValue="reply">
426
+ <TabsList aria-label="Comment">
427
+ <TabsTab value="reply">Reply</TabsTab>
428
+ <TabsTab value="formatting">Formatting</TabsTab>
429
+ <TabsIndicator />
430
+ </TabsList>
431
+ <TabsPanel value="reply" keepMounted>
432
+ <Field>
433
+ <FieldLabel>Message</FieldLabel>
434
+ <Textarea rows={3} placeholder="Write a reply…" />
435
+ </Field>
436
+ </TabsPanel>
437
+ <TabsPanel value="formatting">
438
+ <p>Use **bold**, _italics_ and `code` to format your reply.</p>
439
+ <p>Paste a link on its own line to show a preview.</p>
440
+ </TabsPanel>
441
+ </Tabs>
442
+ )
443
+ }
444
+
445
+ export { Example }
446
+ ```
447
+
448
+ Write a message, switch to Formatting, then return to Reply. Your draft is still there.
449
+
450
+ ## Find in Page
451
+
452
+ Add `hiddenUntilFound` to the tabs or a panel to keep closed content available to the browser’s Find command. A match selects its tab with the reason `find-in-page`. This also keeps the panel mounted.
453
+
454
+ React renders `hidden` as a boolean on the server, so these panels become findable after hydration.
455
+
456
+ ```tsx title="find-in-page.tsx"
457
+ "use client"
458
+
459
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
460
+
461
+ const policies = [
462
+ {
463
+ value: "shipping",
464
+ label: "Shipping",
465
+ text: "Orders leave our warehouse within two working days. Express delivery arrives the next morning.",
466
+ },
467
+ {
468
+ value: "returns",
469
+ label: "Returns",
470
+ text: "Send anything back within 30 days. Opened electronics carry a restocking fee of 10 percent.",
471
+ },
472
+ {
473
+ value: "warranty",
474
+ label: "Warranty",
475
+ text: "Every product has a two-year warranty. Batteries are covered for one year from delivery.",
476
+ },
477
+ ]
478
+
479
+ function Example() {
480
+ return (
481
+ <Tabs defaultValue="shipping" hiddenUntilFound>
482
+ <TabsList aria-label="Policies">
483
+ {policies.map((policy) => (
484
+ <TabsTab key={policy.value} value={policy.value}>
485
+ {policy.label}
486
+ </TabsTab>
487
+ ))}
488
+ </TabsList>
489
+ {policies.map((policy) => (
490
+ <TabsPanel key={policy.value} value={policy.value}>
491
+ {policy.text}
492
+ </TabsPanel>
493
+ ))}
494
+ </Tabs>
495
+ )
496
+ }
497
+
498
+ export { Example }
499
+ ```
500
+
501
+ Use your browser’s Find command to search for “restocking fee”. Returns opens to reveal the match.
502
+
503
+ ## Animation
504
+
505
+ Panels expose `data-starting-style` as they enter and `data-ending-style` as they leave. The previous panel stays mounted through its exit animation, then unmounts or hides if it is kept mounted.
506
+
507
+ Use `data-activation-direction` to choose a slide direction. Put the panels in the same grid cell so they overlap during the transition, as this example does.
508
+
509
+ ```tsx title="animation.tsx"
510
+ "use client"
511
+
512
+ import {
513
+ Tabs,
514
+ TabsIndicator,
515
+ TabsList,
516
+ TabsPanel,
517
+ TabsTab,
518
+ } from "@ui-sdk/react/tabs"
519
+
520
+ function Example() {
521
+ return (
522
+ <Tabs defaultValue="overview">
523
+ <TabsList aria-label="Project">
524
+ <TabsTab value="overview">Overview</TabsTab>
525
+ <TabsTab value="activity">Activity</TabsTab>
526
+ <TabsTab value="settings">Settings</TabsTab>
527
+ <TabsIndicator />
528
+ </TabsList>
529
+ <div data-slot="stack">
530
+ <TabsPanel value="overview">
531
+ The launch is on track for Friday, with 4 of 6 tasks done.
532
+ </TabsPanel>
533
+ <TabsPanel value="activity">
534
+ Inès Moreau deployed to production and Kofi Mensah left a review.
535
+ </TabsPanel>
536
+ <TabsPanel value="settings">
537
+ Rename the project, transfer it to another team or archive it.
538
+ </TabsPanel>
539
+ </div>
540
+ </Tabs>
541
+ )
542
+ }
543
+
544
+ export { Example }
545
+ ```
546
+
547
+ Move between Overview, Activity and Settings. The panels slide in the direction you moved.
548
+
549
+ ## Controlled
550
+
551
+ Use `value` and `onValueChange` to own the selected tab. [State and Events](../state-and-events.md) covers the shared pattern. Call `details.cancel()` in the change callback to reject a change.
552
+
553
+ `onValueChange` receives the new value and a [reason](#reasons), such as `item-press`, `list-navigation`, or `imperative`. It does not run for the initial selection. A [controller](../controllers.md) lets another control select a tab too.
554
+
555
+ ```tsx title="controlled.tsx"
556
+ "use client"
557
+
558
+ import { createTabsController } from "@ui-sdk/core/tabs"
559
+ import {
560
+ Tabs,
561
+ TabsIndicator,
562
+ TabsList,
563
+ TabsPanel,
564
+ TabsTab,
565
+ } from "@ui-sdk/react/tabs"
566
+ import * as React from "react"
567
+ import { useLog } from "./log"
568
+
569
+ function Example() {
570
+ const log = useLog()
571
+ const [tabs] = React.useState(() => createTabsController())
572
+ const [value, setValue] = React.useState<string | null>("inbox")
573
+
574
+ return (
575
+ <div>
576
+ <div data-slot="controls">
577
+ <button type="button" onClick={() => tabs.select("sent")}>
578
+ Show Sent Mail
579
+ </button>
580
+ </div>
581
+ <Tabs
582
+ value={value}
583
+ onValueChange={(next, details) => {
584
+ setValue(next)
585
+ log(`value: ${next} (${details.reason})`)
586
+ }}
587
+ controller={tabs}
588
+ >
589
+ <TabsList aria-label="Mail">
590
+ <TabsTab value="inbox">Inbox</TabsTab>
591
+ <TabsTab value="drafts">Drafts</TabsTab>
592
+ <TabsTab value="sent">Sent</TabsTab>
593
+ <TabsIndicator />
594
+ </TabsList>
595
+ <TabsPanel value="inbox">
596
+ 3 unread messages from Hollis Grant and Inès Moreau.
597
+ </TabsPanel>
598
+ <TabsPanel value="drafts">
599
+ 2 drafts, the last one edited yesterday at 4:12 PM.
600
+ </TabsPanel>
601
+ <TabsPanel value="sent">
602
+ 12 messages sent this week, all delivered.
603
+ </TabsPanel>
604
+ </Tabs>
605
+ </div>
606
+ )
607
+ }
608
+
609
+ export { Example }
610
+ ```
611
+
612
+ Choose Drafts, then press Show Sent Mail. The console logs each new value with its reason.
613
+
614
+ ## Links
615
+
616
+ Render a tab as a link when selection should navigate. It keeps its tab role; arrow keys follow the link when they select it. Modified clicks, such as Cmd-click, keep their normal browser behavior without selecting the tab.
617
+
618
+ ```tsx
619
+ <TabsTab value="activity" render={<a href="#activity" />}>
620
+ Activity
621
+ </TabsTab>
622
+ ```
623
+
624
+ ```tsx title="links.tsx"
625
+ "use client"
626
+
627
+ import {
628
+ Tabs,
629
+ TabsIndicator,
630
+ TabsList,
631
+ TabsPanel,
632
+ TabsTab,
633
+ } from "@ui-sdk/react/tabs"
634
+
635
+ const pages = [
636
+ {
637
+ value: "overview",
638
+ href: "#project-overview",
639
+ label: "Overview",
640
+ content:
641
+ "Hollis Grant started this project in March. It has 14 open issues.",
642
+ },
643
+ {
644
+ value: "activity",
645
+ href: "#project-activity",
646
+ label: "Activity",
647
+ content:
648
+ "Wren Takahashi merged 3 pull requests and closed 5 issues this week.",
649
+ },
650
+ {
651
+ value: "members",
652
+ href: "#project-members",
653
+ label: "Members",
654
+ content:
655
+ "Hollis Grant owns the project. Wren Takahashi and 3 others can edit it.",
656
+ },
657
+ ]
658
+
659
+ function Example() {
660
+ return (
661
+ <Tabs defaultValue="overview">
662
+ <TabsList aria-label="Project">
663
+ {pages.map((page) => (
664
+ <TabsTab
665
+ key={page.value}
666
+ value={page.value}
667
+ render={<a href={page.href} />}
668
+ >
669
+ {page.label}
670
+ </TabsTab>
671
+ ))}
672
+ <TabsIndicator />
673
+ </TabsList>
674
+ {pages.map((page) => (
675
+ <TabsPanel key={page.value} value={page.value}>
676
+ {page.content}
677
+ </TabsPanel>
678
+ ))}
679
+ </Tabs>
680
+ )
681
+ }
682
+
683
+ export { Example }
684
+ ```
685
+
686
+ Choose Activity. Its panel opens and the URL hash changes. Modified clicks keep the link’s usual browser behavior.
687
+
688
+ ## Query String
689
+
690
+ Use the URL as the source of the selected value, and validate it against your tab values. Read the parameter on the server when possible, then pass it as the controlled value. Write changes through your router so browser navigation and the rendered page stay in sync. For a plain client page, keep the rest of the URL when updating it:
691
+
692
+ ```ts
693
+ function saveSelectedTab(value: string | null) {
694
+ const url = new URL(location.href)
695
+ if (value === null) {
696
+ url.searchParams.delete("tab")
697
+ } else {
698
+ url.searchParams.set("tab", value)
699
+ }
700
+ history.replaceState(null, "", url)
701
+ }
702
+ ```
703
+
704
+ Call this from `onValueChange` after accepting the value. Read it again on `popstate` if your page uses browser history directly; remove that listener when the view unmounts.
705
+
706
+ ## URL Hash
707
+
708
+ A hash such as `#activity` works on a client-rendered page. Read it after mount and on `hashchange`, then select the matching tab. Setting `location.hash` adds a history entry. The server cannot read the hash, so give the page an initial tab while it loads.
709
+
710
+ ## Route Tabs
711
+
712
+ When each tab is a route, render [links](#links) and derive the controlled value from the current path. Let navigation update the value. You do not also need a change handler that navigates to the same route.
713
+
714
+ ## Scroll into View
715
+
716
+ If the list scrolls, selecting a tab through a controller or the URL scrolls it into view inside that list. Pointer and arrow-key selection focus the tab, so the browser reveals it as part of focusing it.
717
+
718
+ ## Custom Rendering
719
+
720
+ Use `render` to change a part’s element or add to its content, as in the [links](#links) example. [Parts and Composition](../parts-and-composition.md) covers the shared rendering API. Each part’s state is listed under [State](#state).
721
+
722
+ ```tsx title="render.tsx"
723
+ "use client"
724
+
725
+ import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs"
726
+
727
+ const folders = [
728
+ {
729
+ value: "inbox",
730
+ label: "Inbox",
731
+ count: 12,
732
+ content: "12 conversations, 3 of them unread.",
733
+ },
734
+ {
735
+ value: "unread",
736
+ label: "Unread",
737
+ count: 3,
738
+ content: "Hollis Grant, Inès Moreau and Kofi Mensah wrote to you.",
739
+ },
740
+ {
741
+ value: "archived",
742
+ label: "Archived",
743
+ count: 0,
744
+ content: "Nothing archived yet. Archived mail stays searchable.",
745
+ },
746
+ ]
747
+
748
+ function Example() {
749
+ return (
750
+ <Tabs defaultValue="inbox">
751
+ <TabsList aria-label="Mail">
752
+ {folders.map((folder) => (
753
+ <TabsTab
754
+ key={folder.value}
755
+ value={folder.value}
756
+ render={(props) => (
757
+ <button {...props}>
758
+ {props.children}
759
+ {folder.count > 0 && (
760
+ <span data-slot="badge">{folder.count}</span>
761
+ )}
762
+ </button>
763
+ )}
764
+ >
765
+ {folder.label}
766
+ </TabsTab>
767
+ ))}
768
+ </TabsList>
769
+ {folders.map((folder) => (
770
+ <TabsPanel key={folder.value} value={folder.value}>
771
+ {folder.content}
772
+ </TabsPanel>
773
+ ))}
774
+ </Tabs>
775
+ )
776
+ }
777
+
778
+ export { Example }
779
+ ```
780
+
781
+ Each tab renders its own button with an unread count after the label. Choose Unread to see who wrote to you.
782
+
783
+ ## Styling
784
+
785
+ Parts are unstyled. Use `data-selected` and `data-disabled` to style a tab, and `data-selected` on a panel that shows. `data-orientation` on every part lets one stylesheet lay out horizontal and vertical tabs. Icon parts also set `data-has-icon` on the tab and `data-has-icons` on the list, which can help align mixed text and icon tabs.
786
+
787
+ The indicator’s position and size are measured from the tab list into the variables below. Use them for an underline, a background, or a marker beside a vertical list.
788
+
789
+ Each part has a `data-slot`, such as `tabs-tab`, and its state attributes are listed under [Data Attributes](#data-attributes).
790
+
791
+ ### TabsIndicator
792
+ - `--active-tab-left`: Distance from the tab list's left edge to the selected tab.
793
+ - `--active-tab-right`: Distance from the tab list's right edge to the selected tab.
794
+ - `--active-tab-top`: Distance from the tab list's top edge to the selected tab.
795
+ - `--active-tab-bottom`: Distance from the tab list's bottom edge to the selected tab.
796
+ - `--active-tab-width`: Width of the selected tab.
797
+ - `--active-tab-height`: Height of the selected tab.
798
+
799
+ ## Data Attributes
800
+
801
+ ### Tabs
802
+ `[data-slot="tabs"]`
803
+
804
+ - `data-orientation` (`horizontal`, `vertical`): Which arrow keys move between tabs.
805
+ - `data-activation-direction` (`none`, `left`, `right`, `up`, `down`): Which way the last selection moved on screen. Use it to slide panels in from the right side.
806
+
807
+ ### TabsList
808
+ `[data-slot="tabs-list"]`
809
+
810
+ - `data-orientation` (`horizontal`, `vertical`): Which arrow keys move between tabs.
811
+ - `data-activation-direction` (`none`, `left`, `right`, `up`, `down`): Which way the last selection moved on screen. Use it to slide panels in from the right side.
812
+ - `data-has-icons`: Present while any tab inside holds an icon part, so items without one can line up.
813
+
814
+ ### TabsTab
815
+ `[data-slot="tabs-tab"]`
816
+
817
+ - `data-selected`: Present on the selected tab and its panel.
818
+ - `data-orientation` (`horizontal`, `vertical`): Which arrow keys move between tabs.
819
+ - `data-activation-direction` (`none`, `left`, `right`, `up`, `down`): Which way the last selection moved on screen. Use it to slide panels in from the right side.
820
+ - `data-disabled`: Present when the tab can't be selected.
821
+ - `data-has-icon`: Present on a tab while it holds an icon part.
822
+
823
+ ### TabsTabIcon
824
+ `[data-slot="tabs-tab-icon"]`
825
+
826
+ - `data-mirror`: Present on an icon that flips in right-to-left text, with `mirror`.
827
+
828
+ ### TabsIndicator
829
+ `[data-slot="tabs-indicator"]`
830
+
831
+ - `data-orientation` (`horizontal`, `vertical`): Which arrow keys move between tabs.
832
+ - `data-activation-direction` (`none`, `left`, `right`, `up`, `down`): Which way the last selection moved on screen. Use it to slide panels in from the right side.
833
+
834
+ ### TabsPanel
835
+ `[data-slot="tabs-panel"]`
836
+
837
+ - `data-selected`: Present on the selected tab and its panel.
838
+ - `data-orientation` (`horizontal`, `vertical`): Which arrow keys move between tabs.
839
+ - `data-activation-direction` (`none`, `left`, `right`, `up`, `down`): Which way the last selection moved on screen. Use it to slide panels in from the right side.
840
+ - `data-starting-style`: Present for a panel's first frame. Style the state you animate from.
841
+ - `data-ending-style`: Present while the previous panel animates out. Style the state you animate to.
842
+
843
+ ## API Reference
844
+
845
+ Props and callbacks are the same as below, as React props.
846
+
847
+ ### Tabs
848
+
849
+ - `value?` (`T | null`): The selected tab's value. Pass it to control the tabs. `null` selects nothing.
850
+ - `defaultValue?` (`T | null`): The tab selected at first, when uncontrolled. Defaults to the first enabled tab, which never calls `onValueChange`.
851
+ - `onValueChange?` (`((value: T | null, details: ChangeDetails<TabsValueChangeReason>) => void)`): Runs when the selection wants to change. `details.reason` says why, and `details.cancel()` stops it.
852
+ - `orientation?` (`TabsOrientation`): Which arrow keys move between tabs: left and right, or up and down.
853
+ - `activation?` (`"automatic" | "manual"`): `"automatic"` selects a tab as soon as arrow keys focus it. `"manual"` waits for Enter or Space.
854
+ - `loop?` (`boolean`): Whether arrow keys wrap from the last tab to the first.
855
+ - `hiddenUntilFound?` (`boolean`): Keeps hidden panels in the page as `hidden="until-found"`, so the browser's find in page can match their text and select their tab. Implies `keepMounted`.
856
+ - `controller?` (`{ getValue: () => T | null; setValue: (value: T | null, options?: TabsChangeOptions) => boolean; select: (value: T, options?: TabsChangeOptions) => boolean; focus: () => void; }`): Selects tabs from anywhere. Create one with `createTabsController()`.
857
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
858
+
859
+ ### TabsList
860
+
861
+ The list takes no options of its own, only the props of the element it renders.
862
+
863
+ ### TabsTab
864
+
865
+ - `value` (`string`): Identifies the tab and pairs it with the panel of the same value.
866
+ - `disabled?` (`boolean`): Keeps the tab focusable but stops it from being selected, as the tabs pattern asks.
867
+
868
+ ### TabsTabIcon
869
+
870
+ - `mirror?` (`boolean`): Flips the icon horizontally in right-to-left text, for icons that point a way, like arrows and chevrons. Icons that picture a thing, like a clock or a check, stay as they are.
871
+
872
+ ### TabsIndicator
873
+
874
+ The indicator takes no props of its own. Its [CSS variables](#styling-tabsindicator) hold the selected tab's box.
875
+
876
+ ### TabsPanel
877
+
878
+ - `value` (`string`): The value of the tab this panel belongs to.
879
+ - `keepMounted?` (`boolean`): Whether the panel stays in the page, hidden, while its tab isn't selected.
880
+ - `hiddenUntilFound?` (`boolean`): Whether the panel stays findable with `hidden="until-found"` while its tab isn't selected. Overrides the tabs'.
881
+
882
+ ### State
883
+
884
+ What render functions, state-based class names and slots receive, per part.
885
+
886
+ `Tabs`:
887
+
888
+ - `value` (`T | null`): The selected tab's value.
889
+ - `orientation` (`TabsOrientation`): The tabs' `orientation` option, or `"horizontal"` when it's unset or invalid.
890
+ - `direction` (`Direction`): Which way the last selection moved.
891
+
892
+ `TabsList`:
893
+
894
+ - `orientation` (`TabsOrientation`): The tabs' `orientation` option, or `"horizontal"` when it's unset or invalid.
895
+
896
+ `TabsTab`:
897
+
898
+ - `selected` (`boolean`): Whether this tab's value is the tabs' `value`.
899
+ - `disabled` (`boolean`): Whether this tab can't be selected.
900
+
901
+ `TabsTabIcon`:
902
+
903
+ - `mirror` (`boolean`): Whether it flips in right-to-left text.
904
+
905
+ `TabsPanel`:
906
+
907
+ - `selected` (`boolean`): Whether this panel's tab is selected. False while it animates out.
908
+
909
+ `TabsIndicator`:
910
+
911
+ - `orientation` (`TabsOrientation`): The tabs' `orientation` option, or `"horizontal"` when it's unset or invalid.
912
+ - `direction` (`Direction`): Which way the last selection moved.
913
+
914
+ ### Reasons
915
+
916
+ `details.reason` says why the selection changed.
917
+
918
+ - `item-press` (`MouseEvent | KeyboardEvent`): A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
919
+ - `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.
920
+ - `find-in-page` (`Event`): The browser's find in page matched hidden content.
921
+ - `item-removed` (`none`): The selected item left the page, and another was picked.
922
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
923
+
924
+ ### Controller
925
+
926
+ Create one with `createTabsController()` and pass it as `controller`.
927
+
928
+ Every write method takes an optional `{ reason, event }`, runs `onValueChange` like a press, and returns `false` when the change is canceled.
929
+
930
+ - `getValue()` (`() => T | null`): The selected tab's value, or null when nothing is selected.
931
+ - `setValue(value, options?)` (`(value: T | null, options?: TabsChangeOptions | undefined) => boolean`): Selects a tab, or nothing with `null`. Disabled tabs never select. Returns false when canceled.
932
+ - `select(value, options?)` (`(value: T, options?: TabsChangeOptions | undefined) => boolean`): Selects a tab, the same as `setValue`.
933
+ - `focus()` (`() => void`): Moves focus to the selected tab, or the tab that holds the tab stop.
934
+
935
+ ### Events
936
+
937
+ Callbacks get the new value first, then the details. `onValueChange` never runs on mount.
938
+
939
+ | Prop | On | Receives |
940
+ | --------------- | ------ | ------------------------------------------------------------- |
941
+ | `onValueChange` | `Tabs` | `(value, details)`: the new value, and the [reason](#reasons) |
942
+
943
+ ## Accessibility
944
+
945
+ Tabs follow the [WAI-ARIA tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/). The list is a `tablist`, each tab controls its panel, and each panel is labelled by its tab.
946
+
947
+ ### Keyboard
948
+
949
+ Tab enters the list at the selected tab and leaves it on the next Tab. Left and Right Arrow move between tabs and select them, or only move focus with `activation="manual"`, where Enter or Space selects. Up and Down Arrow do the same in a vertical list. Home and End move to the first and last tabs. The list reads `dir="rtl"` from the page or any ancestor, and Left and Right follow the reading direction, with no provider.
950
+
951
+ ### Tested Behavior
952
+
953
+ Every line below is an automated test.
954
+
955
+ **Selection**
956
+
957
+ - The default tab is selected and shows its panel.
958
+ - Clicking a tab selects it and shows its panel.
959
+ - Clicking a disabled tab does nothing.
960
+ - Clicking the selected tab keeps it selected.
961
+ - A change can be cancelled.
962
+ - Without a default value, the first enabled tab is selected.
963
+ - Without a default value, the first render already selects the first enabled tab.
964
+
965
+ **Keyboard navigation**
966
+
967
+ - Tab moves focus to the selected tab.
968
+ - ArrowRight and ArrowLeft move focus and select the tab.
969
+ - Disabled tabs are focusable but never selected.
970
+ - Focus wraps at both ends.
971
+ - Home and End move to the first and last tabs.
972
+ - ArrowUp and ArrowDown do nothing in a horizontal tab list.
973
+ - Arrow keys with a modifier are left to the browser.
974
+ - Keys pressed in quick succession are never lost.
975
+ - Tab moves focus from the tab list into the selected panel.
976
+ - Shift+Tab from the panel returns to the selected tab.
977
+
978
+ **Manual activation**
979
+
980
+ - Arrow keys move focus without selecting.
981
+ - Enter selects the focused tab.
982
+ - Space selects the focused tab.
983
+ - Enter on a disabled tab does nothing.
984
+
985
+ **Vertical**
986
+
987
+ - The tab list reports its orientation.
988
+ - ArrowDown and ArrowUp move between tabs.
989
+ - ArrowLeft and ArrowRight do nothing in a vertical tab list.
990
+
991
+ **Panels**
992
+
993
+ - The selected tab controls its panel, and the panel is labelled by its tab.
994
+ - With keepMounted, hidden panels stay in the page.
995
+ - With keepMounted, a class that sets display doesn't show hidden panels.
996
+
997
+ Runs in React, Vue and web components.
998
+
999
+ Beyond the pattern's baseline:
1000
+
1001
+ **Enhancements**
1002
+
1003
+ - In manual mode, re-entering the tab list focuses the selected tab.
1004
+ - A panel that holds a field is not a tab stop of its own.
1005
+ - A controller selects a tab from anywhere.
1006
+ - An infinite exit animation still unmounts the panel.
1007
+
1008
+ Runs in React, Vue and web components.
1009
+
1010
+ Screen readers hear the same thing in each tested framework, recorded by a virtual screen reader:
1011
+
1012
+ - Announcements while using the tabs with a keyboard.
1013
+
1014
+ Runs in React, Vue and web components.