@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,982 @@
1
+ # Resizable
2
+
3
+ Resize, collapse, and save panel layouts with pointer and keyboard controls.
4
+
5
+ Use a resizable group to let people size the panes of a layout, like a file list beside an editor, by dragging the handle between them or with the keyboard.
6
+
7
+ ```tsx title="basic.tsx"
8
+ "use client"
9
+
10
+ import {
11
+ Resizable,
12
+ ResizableHandle,
13
+ ResizablePanel,
14
+ } from "@ui-sdk/react/resizable"
15
+
16
+ function Example() {
17
+ return (
18
+ <Resizable>
19
+ <ResizablePanel defaultSize={35} minSize={20}>
20
+ <h3>Files</h3>
21
+ <ul>
22
+ <li>page.tsx</li>
23
+ <li>layout.tsx</li>
24
+ <li>globals.css</li>
25
+ </ul>
26
+ </ResizablePanel>
27
+ <ResizableHandle aria-label="Resize files" />
28
+ <ResizablePanel defaultSize={65} minSize={40}>
29
+ <Resizable orientation="vertical">
30
+ <ResizablePanel defaultSize={60} minSize={30}>
31
+ <h3>page.tsx</h3>
32
+ <span data-slot="hint">Saved just now</span>
33
+ </ResizablePanel>
34
+ <ResizableHandle aria-label="Resize editor" />
35
+ <ResizablePanel defaultSize={40} minSize={30}>
36
+ <h3>Terminal</h3>
37
+ <span data-slot="hint">Ready on port 3000</span>
38
+ </ResizablePanel>
39
+ </Resizable>
40
+ </ResizablePanel>
41
+ </Resizable>
42
+ )
43
+ }
44
+
45
+ export { Example }
46
+ ```
47
+
48
+ Drag the handle beside Files, then the one between page.tsx and Terminal.
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @ui-sdk/react @ui-sdk/core
54
+ ```
55
+
56
+ ## Composition
57
+
58
+ Use the following composition to build a `Resizable`:
59
+
60
+ ```text
61
+ Resizable
62
+ ├── ResizablePanel
63
+ ├── ResizableHandle
64
+ └── ResizablePanel
65
+ ```
66
+
67
+ Put a handle between the panels you want to resize, and name it with `aria-label`, like "Resize files". The group lays its panels out in a row, so give it a size, and each panel's size is a percentage of the space the panels share. A group can sit inside a panel, like an editor above a terminal.
68
+
69
+ ## Usage
70
+
71
+ Import the parts and put them together:
72
+
73
+ ```tsx
74
+ "use client"
75
+
76
+ import {
77
+ Resizable,
78
+ ResizableHandle,
79
+ ResizablePanel,
80
+ } from "@ui-sdk/react/resizable"
81
+
82
+ function Example() {
83
+ return (
84
+ <Resizable>
85
+ <ResizablePanel defaultSize={30}>Files</ResizablePanel>
86
+ <ResizableHandle aria-label="Resize files" />
87
+ <ResizablePanel>Editor</ResizablePanel>
88
+ </Resizable>
89
+ )
90
+ }
91
+
92
+ export { Example }
93
+ ```
94
+
95
+ The panel without `defaultSize` takes what's left, here 70%.
96
+
97
+ ## Build Your Own
98
+
99
+ `@ui-sdk/react/resizable` comes with a ready-made Resizable. If you'd like to build your own, with your own names, start from the `resizable` primitive in `@ui-sdk/core`:
100
+
101
+ ```ts title="split-view.ts"
102
+ "use client"
103
+
104
+ import { resizable } from "@ui-sdk/core/resizable"
105
+ import { createParts } from "@ui-sdk/react/primitive"
106
+
107
+ const {
108
+ Root: SplitView,
109
+ Panel: SplitViewPane,
110
+ Handle: SplitViewDivider,
111
+ } = createParts(resizable, { root: "div", panel: "div", handle: "div" })
112
+
113
+ export { SplitView, SplitViewDivider, SplitViewPane }
114
+ ```
115
+
116
+ ```tsx
117
+ <SplitView>
118
+ <SplitViewPane defaultSize={30}>Files</SplitViewPane>
119
+ <SplitViewDivider aria-label="Resize files" />
120
+ <SplitViewPane>Editor</SplitViewPane>
121
+ </SplitView>
122
+ ```
123
+
124
+ Each part keeps the behavior, state and data attributes of its ready-made counterpart: the root lays the panels out, each pane writes its size to `--resizable-panel-size`, and the divider is the focusable separator. See [Rendering](../rendering.md) and [Custom Parts](../custom-parts.md) for more.
125
+
126
+ ## Vertical
127
+
128
+ Set `orientation="vertical"` to stack the panels, and give the group a height. ArrowUp and ArrowDown move the handle. Every part gets `data-orientation` with the group's direction, so a vertical group's handle is `[data-slot="resizable-handle"][data-orientation="vertical"]`.
129
+
130
+ ```tsx title="vertical.tsx"
131
+ "use client"
132
+
133
+ import {
134
+ Resizable,
135
+ ResizableHandle,
136
+ ResizablePanel,
137
+ } from "@ui-sdk/react/resizable"
138
+
139
+ function Example() {
140
+ return (
141
+ <Resizable orientation="vertical">
142
+ <ResizablePanel defaultSize={45} minSize={25}>
143
+ <h3>Inbox</h3>
144
+ <span data-slot="hint">3 unread messages</span>
145
+ </ResizablePanel>
146
+ <ResizableHandle aria-label="Resize inbox" />
147
+ <ResizablePanel defaultSize={55} minSize={25}>
148
+ <h3>Quarterly report</h3>
149
+ <span data-slot="hint">From Hollis Grant</span>
150
+ </ResizablePanel>
151
+ </Resizable>
152
+ )
153
+ }
154
+
155
+ export { Example }
156
+ ```
157
+
158
+ Drag the handle between Inbox and Quarterly report, or focus it and use ArrowUp and ArrowDown.
159
+
160
+ ## Handle
161
+
162
+ Put anything inside a handle, like a grip that shows it can be dragged. The handle can stay a thin line: its hit area is at least 10 pixels across, centered on it, and 24 for touch, without any styles.
163
+
164
+ ```tsx title="handle.tsx"
165
+ "use client"
166
+
167
+ import {
168
+ Resizable,
169
+ ResizableHandle,
170
+ ResizablePanel,
171
+ } from "@ui-sdk/react/resizable"
172
+
173
+ function Example() {
174
+ return (
175
+ <Resizable>
176
+ <ResizablePanel defaultSize={35} minSize={20}>
177
+ <h3>Channels</h3>
178
+ <ul>
179
+ <li>general</li>
180
+ <li>design</li>
181
+ <li>releases</li>
182
+ </ul>
183
+ </ResizablePanel>
184
+ <ResizableHandle aria-label="Resize channels">
185
+ <div />
186
+ </ResizableHandle>
187
+ <ResizablePanel defaultSize={65} minSize={20}>
188
+ <h3>general</h3>
189
+ <span data-slot="hint">Kofi Mensah: The release notes are ready.</span>
190
+ </ResizablePanel>
191
+ </Resizable>
192
+ )
193
+ }
194
+
195
+ export { Example }
196
+ ```
197
+
198
+ Grab the grip beside Channels, or focus the handle and use the arrow keys.
199
+
200
+ ## Collapsible
201
+
202
+ `collapsible` lets a panel collapse below its `minSize` to `collapsedSize`, 0 by default: by dragging past the midpoint to its collapsed size, with Enter or a double-click on its handle, or through the controller. Dragging back past the same point opens it at its minimum, and Enter restores the size it had. A collapsed panel gets `data-collapsed`, and at size 0 its content leaves the tab order and the accessibility tree.
203
+
204
+ ```tsx title="collapsible.tsx"
205
+ "use client"
206
+
207
+ import {
208
+ Resizable,
209
+ ResizableHandle,
210
+ ResizablePanel,
211
+ } from "@ui-sdk/react/resizable"
212
+ import { FolderIcon, SearchIcon, SettingsIcon } from "lucide-react"
213
+
214
+ function Example() {
215
+ return (
216
+ <Resizable>
217
+ <ResizablePanel defaultSize={30} minSize={25} collapsible collapsedSize="48px">
218
+ <ul>
219
+ <li data-slot="row">
220
+ <FolderIcon aria-hidden="true" />
221
+ <span>Files</span>
222
+ </li>
223
+ <li data-slot="row">
224
+ <SearchIcon aria-hidden="true" />
225
+ <span>Search</span>
226
+ </li>
227
+ <li data-slot="row">
228
+ <SettingsIcon aria-hidden="true" />
229
+ <span>Settings</span>
230
+ </li>
231
+ </ul>
232
+ </ResizablePanel>
233
+ <ResizableHandle aria-label="Resize sidebar">
234
+ <div />
235
+ </ResizableHandle>
236
+ <ResizablePanel minSize={40}>
237
+ <h3>README.md</h3>
238
+ <span data-slot="hint">Edited by Inès Moreau</span>
239
+ </ResizablePanel>
240
+ </Resizable>
241
+ )
242
+ }
243
+
244
+ export { Example }
245
+ ```
246
+
247
+ Drag the sidebar closed to leave only its icons, or focus its handle and press Enter to collapse and restore it.
248
+
249
+ ## Sizes in Pixels
250
+
251
+ Sizes are percentages as numbers, or strings with `%`, `px` or `rem`. Pixel and rem bounds hold as the group resizes, so a navigation with `minSize="160px"` never gets narrower, and a change they cause reports the `resize` reason.
252
+
253
+ ```tsx title="sizes.tsx"
254
+ "use client"
255
+
256
+ import {
257
+ Resizable,
258
+ ResizableHandle,
259
+ ResizablePanel,
260
+ } from "@ui-sdk/react/resizable"
261
+
262
+ function Example() {
263
+ return (
264
+ <Resizable>
265
+ <ResizablePanel defaultSize="200px" minSize="160px" maxSize="320px">
266
+ <h3>Docs</h3>
267
+ <ul>
268
+ <li>Getting Started</li>
269
+ <li>Components</li>
270
+ <li>Guides</li>
271
+ </ul>
272
+ </ResizablePanel>
273
+ <ResizableHandle aria-label="Resize navigation">
274
+ <div />
275
+ </ResizableHandle>
276
+ <ResizablePanel minSize={30}>
277
+ <h3>Getting Started</h3>
278
+ <span data-slot="hint">Install the packages</span>
279
+ </ResizablePanel>
280
+ </Resizable>
281
+ )
282
+ }
283
+
284
+ export { Example }
285
+ ```
286
+
287
+ Resize Docs. It stays between 160 and 320 pixels wide, whatever the width of the group.
288
+
289
+ ## Default Layout
290
+
291
+ `defaultLayout` sets every panel's size at once, in order. Otherwise panels without `defaultSize` share what's left evenly.
292
+
293
+ ```tsx title="default-layout.tsx"
294
+ "use client"
295
+
296
+ import {
297
+ Resizable,
298
+ ResizableHandle,
299
+ ResizablePanel,
300
+ } from "@ui-sdk/react/resizable"
301
+
302
+ function Example() {
303
+ return (
304
+ <Resizable defaultLayout={[25, 35, 40]}>
305
+ <ResizablePanel minSize={15}>
306
+ <h3>Mail</h3>
307
+ <ul>
308
+ <li>Inbox</li>
309
+ <li>Drafts</li>
310
+ <li>Sent</li>
311
+ </ul>
312
+ </ResizablePanel>
313
+ <ResizableHandle aria-label="Resize folders" />
314
+ <ResizablePanel minSize={15}>
315
+ <h3>Inbox</h3>
316
+ <ul>
317
+ <li>Hollis Grant</li>
318
+ <li>Inès Moreau</li>
319
+ <li>Kofi Mensah</li>
320
+ </ul>
321
+ </ResizablePanel>
322
+ <ResizableHandle aria-label="Resize inbox" />
323
+ <ResizablePanel minSize={15}>
324
+ <h3>Quarterly report</h3>
325
+ <span data-slot="hint">From Hollis Grant</span>
326
+ </ResizablePanel>
327
+ </Resizable>
328
+ )
329
+ }
330
+
331
+ export { Example }
332
+ ```
333
+
334
+ The three mail panels start at 25, 35 and 40 percent. Resize any of them.
335
+
336
+ ## Controlled
337
+
338
+ Pass `layout` and `onLayoutChange` to control the group. The layout is one percentage per panel, in order, adding up to 100. Every change carries a [reason](#reasons), like `drag`, `step-key` or `collapse`, and `details.cancel()` keeps the current layout.
339
+
340
+ ```tsx title="controlled.tsx"
341
+ "use client"
342
+
343
+ import {
344
+ Resizable,
345
+ ResizableHandle,
346
+ ResizablePanel,
347
+ } from "@ui-sdk/react/resizable"
348
+ import * as React from "react"
349
+ import { useLog } from "./log"
350
+
351
+ const format = (layout: number[]) => layout.map(Math.round).join(" / ")
352
+
353
+ function Example() {
354
+ const log = useLog()
355
+ const [layout, setLayout] = React.useState([30, 70])
356
+ return (
357
+ <div data-slot="stack">
358
+ <div data-slot="controls">
359
+ <button type="button" onClick={() => setLayout([50, 50])}>
360
+ Split Evenly
361
+ </button>
362
+ <button type="button" onClick={() => setLayout([30, 70])}>
363
+ Reset
364
+ </button>
365
+ </div>
366
+ <Resizable
367
+ layout={layout}
368
+ onLayoutChange={(next, details) => {
369
+ if (format(next) !== format(layout)) {
370
+ log(`${format(next)} (${details.reason})`)
371
+ }
372
+ setLayout(next)
373
+ }}
374
+ >
375
+ <ResizablePanel minSize={20}>
376
+ <h3>Files</h3>
377
+ <ul>
378
+ <li>page.tsx</li>
379
+ <li>layout.tsx</li>
380
+ <li>globals.css</li>
381
+ </ul>
382
+ </ResizablePanel>
383
+ <ResizableHandle aria-label="Resize files" />
384
+ <ResizablePanel minSize={20}>
385
+ <h3>page.tsx</h3>
386
+ <span data-slot="hint">Saved just now</span>
387
+ </ResizablePanel>
388
+ </Resizable>
389
+ </div>
390
+ )
391
+ }
392
+
393
+ export { Example }
394
+ ```
395
+
396
+ Resize Files to log the layout and its reason. Split Evenly and Reset set the layout from outside.
397
+
398
+ ## Saving on Complete
399
+
400
+ `onLayoutChange` runs on every frame of a drag. `onLayoutCommit` runs once, when the interaction that changed the layout ends: the pointer lifts, the key comes up, or a panel collapses. Save there.
401
+
402
+ ```tsx title="complete.tsx"
403
+ "use client"
404
+
405
+ import {
406
+ Resizable,
407
+ ResizableHandle,
408
+ ResizablePanel,
409
+ } from "@ui-sdk/react/resizable"
410
+ import { useLog } from "./log"
411
+
412
+ function Example() {
413
+ const log = useLog()
414
+ return (
415
+ <Resizable
416
+ onLayoutCommit={(layout, details) =>
417
+ log(`Saved ${layout.map(Math.round).join(" / ")} (${details.reason})`)
418
+ }
419
+ >
420
+ <ResizablePanel defaultSize={40} minSize={20}>
421
+ <h3>Files</h3>
422
+ <ul>
423
+ <li>page.tsx</li>
424
+ <li>layout.tsx</li>
425
+ <li>globals.css</li>
426
+ </ul>
427
+ </ResizablePanel>
428
+ <ResizableHandle aria-label="Resize files" />
429
+ <ResizablePanel minSize={20}>
430
+ <h3>page.tsx</h3>
431
+ <span data-slot="hint">Saved just now</span>
432
+ </ResizablePanel>
433
+ </Resizable>
434
+ )
435
+ }
436
+
437
+ export { Example }
438
+ ```
439
+
440
+ Drag the handle and release it, or press an arrow key. The console logs the layout once, when you let go.
441
+
442
+ ## Persistence
443
+
444
+ `autoSaveId` saves the layout in `localStorage` when an interaction completes and restores it when the group attaches in the browser. Server markup starts with the default sizes. Each set of panels keeps its own layout, so a panel that comes and goes gets its sizes back. Give panels an `id` so the saved layout survives changes elsewhere on the page.
445
+
446
+ It's the same idea as [Preferences](./preferences.md), which saves one choice between visits, like a theme. Resizable saves the whole layout, under its `autoSaveId`.
447
+
448
+ ```tsx title="persistence.tsx"
449
+ "use client"
450
+
451
+ import {
452
+ Resizable,
453
+ ResizableHandle,
454
+ ResizablePanel,
455
+ } from "@ui-sdk/react/resizable"
456
+
457
+ function Example() {
458
+ return (
459
+ <Resizable autoSaveId="docs-persistence">
460
+ <ResizablePanel id="docs-sidebar" defaultSize={30} minSize={20}>
461
+ <h3>Outline</h3>
462
+ <ul>
463
+ <li>Introduction</li>
464
+ <li>Installation</li>
465
+ <li>Usage</li>
466
+ </ul>
467
+ </ResizablePanel>
468
+ <ResizableHandle aria-label="Resize outline">
469
+ <div />
470
+ </ResizableHandle>
471
+ <ResizablePanel id="docs-content" minSize={30}>
472
+ <h3>Introduction</h3>
473
+ <span data-slot="hint">Last edited by Wren Takahashi</span>
474
+ </ResizablePanel>
475
+ </Resizable>
476
+ )
477
+ }
478
+
479
+ export { Example }
480
+ ```
481
+
482
+ Resize Outline, then reload this page to restore its saved width.
483
+
484
+ ## Storage
485
+
486
+ `storage` takes anything with `getItem` and `setItem`, like `sessionStorage` or a cookie. That's the browser's storage shape, not the [storage](./preferences.md#save-the-value) helpers Preferences takes, such as `createLocalStorage`, which each keep one value. Choose between local storage, session storage and a cookie as you would for a preference, under [Remember the Choice](../core.md#remember-the-choice).
487
+
488
+ This example keeps the layout in `sessionStorage`, for the tab's session:
489
+
490
+ ```tsx title="storage.tsx"
491
+ "use client"
492
+
493
+ import {
494
+ Resizable,
495
+ ResizableHandle,
496
+ ResizablePanel,
497
+ type ResizableStorage,
498
+ } from "@ui-sdk/react/resizable"
499
+
500
+ const session: ResizableStorage = {
501
+ getItem: (key) => sessionStorage.getItem(key),
502
+ setItem: (key, value) => sessionStorage.setItem(key, value),
503
+ }
504
+
505
+ function Example() {
506
+ return (
507
+ <Resizable autoSaveId="docs-storage" storage={session}>
508
+ <ResizablePanel id="session-chats" defaultSize={35} minSize={20}>
509
+ <h3>Messages</h3>
510
+ <ul>
511
+ <li>Inès Moreau</li>
512
+ <li>Kofi Mensah</li>
513
+ <li>Wren Takahashi</li>
514
+ </ul>
515
+ </ResizablePanel>
516
+ <ResizableHandle aria-label="Resize messages" />
517
+ <ResizablePanel id="session-thread" minSize={20}>
518
+ <h3>Inès Moreau</h3>
519
+ <span data-slot="hint">Can we move the review to Friday?</span>
520
+ </ResizablePanel>
521
+ </Resizable>
522
+ )
523
+ }
524
+
525
+ export { Example }
526
+ ```
527
+
528
+ Resize Messages, then reload. The width comes back in this tab, but not in a new one.
529
+
530
+ A server can't read `localStorage`, so it renders each panel's `defaultSize` and the saved layout arrives when the page hydrates. To render the saved layout on the first paint, keep it in a cookie and pass the sizes back as each panel's `defaultSize`. Here a Next.js page reads the cookie on the server. It imports `resizableStorageKey`, which names the cookie, from `@ui-sdk/core/resizable`, since the component entries are client modules:
531
+
532
+ ```tsx title="app/page.tsx"
533
+ import { resizableStorageKey } from "@ui-sdk/core/resizable"
534
+ import { cookies } from "next/headers"
535
+ import { Editor } from "./editor"
536
+
537
+ export default async function Page() {
538
+ const saved = JSON.parse(
539
+ (await cookies()).get(resizableStorageKey("editor"))?.value ?? "{}"
540
+ )
541
+ const [sidebar = 25, main = 75] = saved["sidebar,main"] ?? []
542
+ return <Editor sidebar={sidebar} main={main} />
543
+ }
544
+ ```
545
+
546
+ ```tsx title="app/editor.tsx"
547
+ "use client"
548
+
549
+ import {
550
+ Resizable,
551
+ ResizableHandle,
552
+ ResizablePanel,
553
+ type ResizableStorage,
554
+ } from "@ui-sdk/react/resizable"
555
+
556
+ const cookieStorage: ResizableStorage = {
557
+ getItem: (key) => {
558
+ const value = document.cookie.match(
559
+ new RegExp(`(?:^|; )${key}=([^;]*)`)
560
+ )?.[1]
561
+ return value === undefined ? null : decodeURIComponent(value)
562
+ },
563
+ setItem: (key, value) => {
564
+ document.cookie = `${key}=${encodeURIComponent(value)}; path=/; max-age=31536000`
565
+ },
566
+ }
567
+
568
+ function Editor({ sidebar, main }: { sidebar: number; main: number }) {
569
+ return (
570
+ <Resizable autoSaveId="editor" storage={cookieStorage}>
571
+ <ResizablePanel id="sidebar" defaultSize={sidebar} />
572
+ <ResizableHandle aria-label="Resize sidebar" />
573
+ <ResizablePanel id="main" defaultSize={main} />
574
+ </Resizable>
575
+ )
576
+ }
577
+
578
+ export { Editor }
579
+ ```
580
+
581
+ ## Controller
582
+
583
+ A controller, from `createResizableController()`, collapses, expands and resizes panels from anywhere, by id or index, and reads the layout with `getLayout()`. Changes it makes report the `imperative` reason.
584
+
585
+ ```tsx title="controller.tsx"
586
+ "use client"
587
+
588
+ import {
589
+ createResizableController,
590
+ Resizable,
591
+ ResizableHandle,
592
+ ResizablePanel,
593
+ } from "@ui-sdk/react/resizable"
594
+ import * as React from "react"
595
+ import { useLog } from "./log"
596
+
597
+ function Example() {
598
+ const log = useLog()
599
+ const [editor] = React.useState(createResizableController)
600
+ return (
601
+ <div data-slot="stack">
602
+ <div data-slot="controls">
603
+ <button
604
+ type="button"
605
+ onClick={() => editor.collapse("controller-sidebar")}
606
+ >
607
+ Collapse
608
+ </button>
609
+ <button
610
+ type="button"
611
+ onClick={() => editor.expand("controller-sidebar")}
612
+ >
613
+ Expand
614
+ </button>
615
+ <button
616
+ type="button"
617
+ onClick={() => editor.resize("controller-sidebar", "240px")}
618
+ >
619
+ 240px
620
+ </button>
621
+ <button
622
+ type="button"
623
+ onClick={() =>
624
+ log(
625
+ `Layout ${editor.getLayout().map(Math.round).join(" / ")}${editor.isCollapsed("controller-sidebar") ? ", collapsed" : ""}`
626
+ )
627
+ }
628
+ >
629
+ Read
630
+ </button>
631
+ </div>
632
+ <Resizable controller={editor}>
633
+ <ResizablePanel id="controller-sidebar" defaultSize={30} minSize={20} collapsible>
634
+ <h3>Files</h3>
635
+ <ul>
636
+ <li>page.tsx</li>
637
+ <li>layout.tsx</li>
638
+ <li>globals.css</li>
639
+ </ul>
640
+ </ResizablePanel>
641
+ <ResizableHandle aria-label="Resize files" />
642
+ <ResizablePanel minSize={30}>
643
+ <h3>page.tsx</h3>
644
+ <span data-slot="hint">Saved just now</span>
645
+ </ResizablePanel>
646
+ </Resizable>
647
+ </div>
648
+ )
649
+ }
650
+
651
+ export { Example }
652
+ ```
653
+
654
+ Use Collapse, Expand and 240px to move Files from outside the group, and Read to log its sizes.
655
+
656
+ ## Step Size
657
+
658
+ `step` sets how far an arrow key moves a handle, 1% by default, and `largeStep` how far Shift with an arrow moves it, 10% by default.
659
+
660
+ ```tsx title="keyboard.tsx"
661
+ "use client"
662
+
663
+ import {
664
+ Resizable,
665
+ ResizableHandle,
666
+ ResizablePanel,
667
+ } from "@ui-sdk/react/resizable"
668
+
669
+ function Example() {
670
+ return (
671
+ <Resizable step={5} largeStep={25}>
672
+ <ResizablePanel defaultSize={50} minSize={20}>
673
+ <h3>Original</h3>
674
+ <span data-slot="hint">v1.2.0</span>
675
+ </ResizablePanel>
676
+ <ResizableHandle aria-label="Resize original" />
677
+ <ResizablePanel defaultSize={50} minSize={20}>
678
+ <h3>Changes</h3>
679
+ <span data-slot="hint">v1.3.0</span>
680
+ </ResizablePanel>
681
+ </Resizable>
682
+ )
683
+ }
684
+
685
+ export { Example }
686
+ ```
687
+
688
+ Focus the handle between Original and Changes. The arrow keys move it 5%, Shift with an arrow 25%, and Home and End as far as it goes.
689
+
690
+ ## Disabled
691
+
692
+ `disabled` on a handle fixes it in place. On the group it fixes every handle. Disabled handles leave the tab order, and their panels keep their sizes. A disabled `<fieldset>` around the group fixes every handle too.
693
+
694
+ ```tsx title="disabled.tsx"
695
+ "use client"
696
+
697
+ import { Checkbox, CheckboxIndicator } from "@ui-sdk/react/checkbox"
698
+ import {
699
+ Resizable,
700
+ ResizableHandle,
701
+ ResizablePanel,
702
+ } from "@ui-sdk/react/resizable"
703
+ import { CheckIcon } from "lucide-react"
704
+ import * as React from "react"
705
+
706
+ function Example() {
707
+ const [locked, setLocked] = React.useState(false)
708
+ return (
709
+ <div data-slot="stack">
710
+ <div data-slot="controls">
711
+ <label data-slot="label">
712
+ <Checkbox
713
+ checked={locked}
714
+ onCheckedChange={(next) => setLocked(next === true)}
715
+ >
716
+ <CheckboxIndicator>
717
+ <CheckIcon aria-hidden="true" />
718
+ </CheckboxIndicator>
719
+ </Checkbox>
720
+ Lock layout
721
+ </label>
722
+ </div>
723
+ <Resizable disabled={locked}>
724
+ <ResizablePanel minSize={15}>
725
+ <h3>Pinned</h3>
726
+ <span data-slot="hint">2 notes</span>
727
+ </ResizablePanel>
728
+ <ResizableHandle disabled aria-label="Resize pinned" />
729
+ <ResizablePanel minSize={15}>
730
+ <h3>Inbox</h3>
731
+ <span data-slot="hint">3 unread</span>
732
+ </ResizablePanel>
733
+ <ResizableHandle aria-label="Resize inbox" />
734
+ <ResizablePanel minSize={15}>
735
+ <h3>Message</h3>
736
+ <span data-slot="hint">From Kofi Mensah</span>
737
+ </ResizablePanel>
738
+ </Resizable>
739
+ </div>
740
+ )
741
+ }
742
+
743
+ export { Example }
744
+ ```
745
+
746
+ The handle after Pinned stays fixed. Drag the one after Inbox, then check Lock layout to fix it too.
747
+
748
+ ## Custom Rendering
749
+
750
+ `render`, `className` and `children` can be functions of the part's state, like a panel's `size` and whether it's `collapsed`, or whether a handle is `dragging` or `hovering`. See [Parts and Composition](../parts-and-composition.md) for the rendering contract.
751
+
752
+ ```tsx title="render.tsx"
753
+ "use client"
754
+
755
+ import {
756
+ Resizable,
757
+ ResizableHandle,
758
+ ResizablePanel,
759
+ } from "@ui-sdk/react/resizable"
760
+
761
+ function Example() {
762
+ return (
763
+ <Resizable>
764
+ <ResizablePanel defaultSize={35} minSize={20} collapsible>
765
+ {(state) => (
766
+ <>
767
+ <h3>Files</h3>
768
+ <span data-slot="hint">
769
+ {state.collapsed ? "Collapsed" : `${Math.round(state.size)}%`}
770
+ </span>
771
+ </>
772
+ )}
773
+ </ResizablePanel>
774
+ <ResizableHandle aria-label="Resize files" render={<div />} />
775
+ <ResizablePanel minSize={30}>
776
+ {(state) => (
777
+ <>
778
+ <h3>Editor</h3>
779
+ <span data-slot="hint">{`${Math.round(state.size)}%`}</span>
780
+ </>
781
+ )}
782
+ </ResizablePanel>
783
+ </Resizable>
784
+ )
785
+ }
786
+
787
+ export { Example }
788
+ ```
789
+
790
+ Resize Files to see both panels report their size, or collapse it to see Collapsed.
791
+
792
+ The primitive writes drag sizes directly to panel styles. Reading `size` or `layout` in a render function also renders that part on every frame of the drag.
793
+
794
+ ## Styling
795
+
796
+ Parts are unstyled, apart from the layout they need: the group is a flex row or column, panels take their size as a flex basis, and handles don't shrink and take `touch-action: none`. Give the group a size, the handle a width or height and a background, and style it with `data-hovering`, `data-dragging` and `:focus-visible`. While a handle is hovered or dragged, its cursor shows over the whole page, and points the only way it can go at a limit.
797
+
798
+ Each part has a `data-slot`, such as `resizable-handle`, and its state attributes are listed under [Data Attributes](#data-attributes).
799
+
800
+ ### ResizablePanel
801
+ - `--resizable-panel-size`: The panel's share of the group, as a percentage. Written on every frame of a drag, without a render.
802
+
803
+ ## Data Attributes
804
+
805
+ ### Resizable
806
+ `[data-slot="resizable"]`
807
+
808
+ - `data-orientation` (`horizontal`, `vertical`): The group's direction, on every part. A handle's own `aria-orientation` is the other one, since it runs across the group.
809
+ - `data-disabled`: Present when the group, or this handle, is disabled.
810
+ - `data-dragging`: Present while a handle of the group is being dragged.
811
+
812
+ ### ResizablePanel
813
+ `[data-slot="resizable-panel"]`
814
+
815
+ - `data-orientation` (`horizontal`, `vertical`): The group's direction, on every part. A handle's own `aria-orientation` is the other one, since it runs across the group.
816
+ - `data-collapsed`: Present while a collapsible panel is collapsed.
817
+
818
+ ### ResizableHandle
819
+ `[data-slot="resizable-handle"]`
820
+
821
+ - `data-orientation` (`horizontal`, `vertical`): The group's direction, on every part. A handle's own `aria-orientation` is the other one, since it runs across the group.
822
+ - `data-disabled`: Present when the group, or this handle, is disabled.
823
+ - `data-dragging`: Present while this handle is being dragged.
824
+ - `data-hovering`: Present while the pointer is over the handle or within its hit area, which reaches past the handle itself.
825
+
826
+ ## API Reference
827
+
828
+ Props and callbacks are the same as below, as React props.
829
+
830
+ ### Resizable
831
+
832
+ - `layout?` (`number[]`): Each panel's size in percent, in panel order, like `[25, 75]`. Pass it to control the group.
833
+ - `defaultLayout?` (`number[]`): The layout at first, when uncontrolled. Panels' own `defaultSize` is what a server renders, so prefer that with server rendering.
834
+ - `onLayoutChange?` (`((layout: number[], details: ResizableLayoutChangeDetails) => void)`): Runs while the layout changes: on every frame of a drag and every key. `details.cancel()` keeps the layout.
835
+ - `onLayoutCommit?` (`((layout: number[], details: ResizableLayoutCommitDetails) => void)`): Runs once an interaction that changed the layout ends: the pointer lifts, the key comes up, or a panel collapses. For saving.
836
+ - `orientation?` (`"horizontal" | "vertical"`): The direction panels are laid out in. Horizontal panels sit side by side, vertical ones stack.
837
+ - `disabled?` (`boolean`): Stops every handle: no drags, no keys, and handles leave the tab order.
838
+ - `step?` (`number`): How far an arrow key moves a handle, in percent.
839
+ - `largeStep?` (`number`): How far Shift with an arrow key moves a handle, in percent.
840
+ - `autoSaveId?` (`string`): Saves the layout when an interaction completes and restores it on the next visit, under this key. Give panels an `id` so it survives changes elsewhere on the page.
841
+ - `storage?` (`ResizableStorage`): Where `autoSaveId` saves: anything with `getItem` and `setItem`, like a cookie store a server can read.
842
+ - `controller?` (`object`): Resizes the group from anywhere. Create one with `createResizableController()`.
843
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
844
+
845
+ ### ResizablePanel
846
+
847
+ - `id?` (`string`): Identifies the panel for the controller, `aria-controls` and saved layouts. It's the element's id. Generated when left out.
848
+ - `defaultSize?` (`ResizableSize`): Where the panel starts, in percent or with a unit, like `30` or `"240px"`. Without one, panels share what's left evenly. A server renders this size.
849
+ - `minSize?` (`ResizableSize`): The smallest the panel gets while open.
850
+ - `maxSize?` (`ResizableSize`): The largest the panel gets.
851
+ - `collapsible?` (`boolean`): Lets the panel collapse below its minimum to `collapsedSize`: by dragging past half the way there, with Enter or a double-click on its handle, or through the controller.
852
+ - `collapsedSize?` (`ResizableSize`): The size a collapsible panel collapses to. At 0, its content leaves the tab order and the accessibility tree.
853
+
854
+ ### ResizableHandle
855
+
856
+ - `disabled?` (`boolean`): Stops this handle: no drags and no keys, and it leaves the tab order.
857
+
858
+ ### State
859
+
860
+ What render functions, state-based class names and slots receive.
861
+
862
+ - `orientation` (`"horizontal" | "vertical"`): The direction panels are laid out in.
863
+ - `disabled` (`boolean`): Whether the group is disabled.
864
+ - `dragging` (`boolean`): Whether a handle is being dragged.
865
+ - `layout` (`number[]`): Each panel's size in percent. Reading it renders on every frame of a drag.
866
+
867
+ Panels:
868
+
869
+ - `orientation` (`"horizontal" | "vertical"`): The direction panels are laid out in.
870
+ - `size` (`number`): The panel's size in percent. Reading it renders on every frame of a drag.
871
+ - `collapsed` (`boolean`): Whether the panel is down at its `collapsedSize`, below its minimum.
872
+ - `collapsible` (`boolean`): Whether the panel can collapse.
873
+
874
+ Handles:
875
+
876
+ - `orientation` (`"horizontal" | "vertical"`): The direction panels are laid out in. The separator itself runs across it.
877
+ - `disabled` (`boolean`): Whether the handle can't move.
878
+ - `dragging` (`boolean`): Whether the handle is being dragged.
879
+ - `hovering` (`boolean`): Whether the pointer is over the handle or within its hit area.
880
+
881
+ ### Reasons
882
+
883
+ `details.reason` says why the layout changed.
884
+
885
+ - `drag` (`PointerEvent`): A slider thumb or a resize handle was dragged, or an item was dragged to a new place in a list.
886
+ - `step-key` (`KeyboardEvent`): Arrow, Page Up, Page Down, Home or End stepped a slider or a number input.
887
+ - `collapse` (`MouseEvent | KeyboardEvent`): Enter or a double-click on a resize handle collapsed the panel beside it, or restored it.
888
+ - `resize` (`none`): The group changed size, so panels with sizes in pixels moved to stay within their bounds.
889
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
890
+
891
+ ### Controller
892
+
893
+ Create one with `createResizableController()` and pass it as `controller`.
894
+
895
+ Write methods take an optional `{ reason, event }`, run the change callback like a drag, and return `false` when nothing changed or the change was canceled.
896
+
897
+ - `getLayout()` (`() => number[]`): Each panel's size in percent, in order.
898
+ - `setLayout(layout, options?)` (`(layout: number[], options?: ResizableChangeOptions | undefined) => boolean`): Sets every panel's size at once, in percent. It's fitted to the panels' bounds and adds up to 100. Returns whether anything changed.
899
+ - `collapse(panel, options?)` (`(panel: string | number, options?: ResizableChangeOptions | undefined) => boolean`): Collapses a collapsible panel, by its id or its index. Returns whether it collapsed.
900
+ - `expand(panel, options?)` (`(panel: string | number, options?: ResizableChangeOptions | undefined) => boolean`): Expands a collapsed panel to the size it had before it collapsed, or its minimum. Returns whether it expanded.
901
+ - `resize(panel, size, options?)` (`(panel: string | number, size: ResizableSize, options?: ResizableChangeOptions | undefined) => boolean`): Resizes one panel, by its id or its index, like `resize("sidebar", "240px")`. Its neighbours give or take the difference.
902
+ - `isCollapsed(panel)` (`(panel: string | number) => boolean`): Whether a panel is collapsed.
903
+
904
+ ### Events
905
+
906
+ Callbacks get the new layout first, then the details.
907
+
908
+ | Prop | On | Receives |
909
+ | ---------------- | ----------- | -------------------------------------------------------------- |
910
+ | `onLayoutChange` | `Resizable` | `(layout, details)`: the new layout and the [reason](#reasons) |
911
+ | `onLayoutCommit` | `Resizable` | `(layout, details)`: the layout once the interaction ends |
912
+
913
+ ## Accessibility
914
+
915
+ Handles follow the [WAI-ARIA window splitter pattern](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/). Each is a focusable `separator` whose `aria-valuenow` is the size of the panel before it, with `aria-valuemin` and `aria-valuemax` as far as the panels allow, `aria-controls` pointing at that panel, and `aria-orientation` running across the group. Name each handle with `aria-label`.
916
+
917
+ ### Keyboard
918
+
919
+ Focus a handle and press the arrow keys along the group's axis to move it by `step`, or with Shift by `largeStep`. Home and End move it as far as the panels allow, and Enter collapses or restores a collapsible panel beside it. A panel at its minimum passes the rest of a move on to the next one. Disabled handles leave the tab order.
920
+
921
+ ### Tested Behavior
922
+
923
+ Every line below is an automated test.
924
+
925
+ **Keyboard**
926
+
927
+ - Starts at each panel's default size, and panels without one share the rest.
928
+ - ArrowRight grows the panel before the handle by one step, and ArrowLeft shrinks it.
929
+ - Shift with an arrow key moves by the large step.
930
+ - Arrows across the group's axis do nothing.
931
+ - ArrowDown and ArrowUp move a vertical group's handle.
932
+ - Home collapses a collapsible panel, and End grows it to its maximum.
933
+ - Home stops at the minimum of a panel that can't collapse.
934
+ - Enter collapses the panel before the handle, and restores its size.
935
+ - Enter collapses the panel after the handle when only that one can collapse.
936
+ - One step past a collapsible panel's minimum collapses it.
937
+ - A panel at its minimum passes the rest on to the next one.
938
+ - End stops where the panels' bounds meet.
939
+ - Keys pressed without waiting all land.
940
+ - Keys complete the change once they come up.
941
+ - Step and large step set how far keys move.
942
+ - A canceled change keeps the layout.
943
+ - A controlled group follows its layout.
944
+ - A controlled group that ignores a change completes nothing. React and Vue only.
945
+ - A disabled handle stops a move from the next one, so the panels past it keep their sizes.
946
+ - DefaultLayout sets where the panels start.
947
+ - A disabled group's handles leave the tab order and ignore drags.
948
+
949
+ **Pointer**
950
+
951
+ - Dragging a handle moves it with the pointer.
952
+ - A drag reports its moves with the drag reason and completes once.
953
+ - Dragging past a disabled handle moves nothing beyond it.
954
+ - Dragging a vertical group's handle moves it up and down.
955
+ - Dragging past half a collapsible panel's minimum collapses it, and back opens it.
956
+ - A drag stops at the panels' bounds.
957
+ - A double-click on a handle collapses its panel, and another restores it.
958
+ - A press just beside the thin handle drags it.
959
+ - A press farther from the handle doesn't drag.
960
+ - Where two handles meet, one drag moves both.
961
+ - A drag shows the axis cursor over the whole page until it ends.
962
+
963
+ **Controller**
964
+
965
+ - Collapses and expands a panel, with the imperative reason.
966
+ - Resizes a panel to a size in pixels.
967
+
968
+ **Container**
969
+
970
+ - A panel with a minimum in pixels keeps it as the group shrinks.
971
+ - Panels keep their share as the group grows.
972
+
973
+ **Pages around a group**
974
+
975
+ - A layer above a handle keeps its presses.
976
+ - A press beside a handle doesn't click what's under it.
977
+ - Only the main button drags.
978
+ - An iframe under the pointer doesn't stop a drag.
979
+ - At a limit, the cursor points the only way a handle can go.
980
+ - A saved layout is there on the first paint.
981
+
982
+ Runs in React, Vue and web components.