@ui-sdk/vue 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 (262) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/accordion.d.ts +561 -0
  4. package/dist/accordion.js +24 -0
  5. package/dist/agent.d.ts +2 -0
  6. package/dist/agent.js +7 -0
  7. package/dist/alert-dialog.d.ts +231 -0
  8. package/dist/alert-dialog.js +33 -0
  9. package/dist/async-options.d.ts +18 -0
  10. package/dist/async-options.js +40 -0
  11. package/dist/autocomplete.d.ts +384 -0
  12. package/dist/autocomplete.js +344 -0
  13. package/dist/avatar.d.ts +40 -0
  14. package/dist/avatar.js +28 -0
  15. package/dist/button.d.ts +52 -0
  16. package/dist/button.js +43 -0
  17. package/dist/calendar-context.d.ts +10 -0
  18. package/dist/calendar-context.js +7 -0
  19. package/dist/calendar.d.ts +311 -0
  20. package/dist/calendar.js +349 -0
  21. package/dist/carousel.d.ts +236 -0
  22. package/dist/carousel.js +204 -0
  23. package/dist/checkbox.d.ts +211 -0
  24. package/dist/checkbox.js +151 -0
  25. package/dist/children.d.ts +41 -0
  26. package/dist/children.js +135 -0
  27. package/dist/collapsible.d.ts +54 -0
  28. package/dist/collapsible.js +18 -0
  29. package/dist/color-picker.d.ts +187 -0
  30. package/dist/color-picker.js +158 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +21 -0
  33. package/dist/combobox.d.ts +517 -0
  34. package/dist/combobox.js +531 -0
  35. package/dist/command.d.ts +322 -0
  36. package/dist/command.js +345 -0
  37. package/dist/controller-target.d.ts +49 -0
  38. package/dist/controller-target.js +112 -0
  39. package/dist/create-parts.d.ts +126 -0
  40. package/dist/create-parts.js +206 -0
  41. package/dist/date-input.d.ts +133 -0
  42. package/dist/date-input.js +31 -0
  43. package/dist/date-picker.d.ts +328 -0
  44. package/dist/date-picker.js +354 -0
  45. package/dist/date.d.ts +2 -0
  46. package/dist/date.js +59 -0
  47. package/dist/dialog-parts.d.ts +259 -0
  48. package/dist/dialog-parts.js +300 -0
  49. package/dist/dialog.d.ts +251 -0
  50. package/dist/dialog.js +25 -0
  51. package/dist/drawer.d.ts +304 -0
  52. package/dist/drawer.js +373 -0
  53. package/dist/editor-context.d.ts +4 -0
  54. package/dist/editor-context.js +5 -0
  55. package/dist/field-context.d.ts +26 -0
  56. package/dist/field-context.js +44 -0
  57. package/dist/field.d.ts +154 -0
  58. package/dist/field.js +240 -0
  59. package/dist/file-input.d.ts +212 -0
  60. package/dist/file-input.js +255 -0
  61. package/dist/form-inputs.d.ts +16 -0
  62. package/dist/form-inputs.js +25 -0
  63. package/dist/gesture.d.ts +1 -0
  64. package/dist/gesture.js +15 -0
  65. package/dist/history.d.ts +2 -0
  66. package/dist/history.js +11 -0
  67. package/dist/hover-card.d.ts +137 -0
  68. package/dist/hover-card.js +153 -0
  69. package/dist/image-cropper.d.ts +74 -0
  70. package/dist/image-cropper.js +36 -0
  71. package/dist/image.d.ts +2 -0
  72. package/dist/image.js +5 -0
  73. package/dist/index.d.ts +59 -0
  74. package/dist/index.js +60 -0
  75. package/dist/input.d.ts +120 -0
  76. package/dist/input.js +73 -0
  77. package/dist/item-icon.d.ts +34 -0
  78. package/dist/item-icon.js +63 -0
  79. package/dist/label.d.ts +16 -0
  80. package/dist/label.js +8 -0
  81. package/dist/lifecycle.d.ts +11 -0
  82. package/dist/lifecycle.js +91 -0
  83. package/dist/list-items.d.ts +38 -0
  84. package/dist/list-items.js +59 -0
  85. package/dist/list-text.d.ts +7 -0
  86. package/dist/list-text.js +15 -0
  87. package/dist/listbox.d.ts +273 -0
  88. package/dist/listbox.js +126 -0
  89. package/dist/menu.d.ts +678 -0
  90. package/dist/menu.js +607 -0
  91. package/dist/menubar-context.d.ts +5 -0
  92. package/dist/menubar-context.js +5 -0
  93. package/dist/menubar.d.ts +61 -0
  94. package/dist/menubar.js +48 -0
  95. package/dist/meter.d.ts +41 -0
  96. package/dist/meter.js +37 -0
  97. package/dist/navigation-menu.d.ts +228 -0
  98. package/dist/navigation-menu.js +195 -0
  99. package/dist/number-input.d.ts +176 -0
  100. package/dist/number-input.js +231 -0
  101. package/dist/number.d.ts +2 -0
  102. package/dist/number.js +39 -0
  103. package/dist/nuxt/entries.json +977 -0
  104. package/dist/nuxt/module.d.ts +18 -0
  105. package/dist/nuxt/module.js +31 -0
  106. package/dist/nuxt/registrations.d.ts +22 -0
  107. package/dist/nuxt/registrations.js +22 -0
  108. package/dist/observe.d.ts +2 -0
  109. package/dist/observe.js +7 -0
  110. package/dist/otp-input.d.ts +142 -0
  111. package/dist/otp-input.js +130 -0
  112. package/dist/overlays.d.ts +40 -0
  113. package/dist/overlays.js +118 -0
  114. package/dist/pagination.d.ts +201 -0
  115. package/dist/pagination.js +146 -0
  116. package/dist/password-input.d.ts +144 -0
  117. package/dist/password-input.js +134 -0
  118. package/dist/popover.d.ts +211 -0
  119. package/dist/popover.js +258 -0
  120. package/dist/popup.d.ts +60 -0
  121. package/dist/popup.js +89 -0
  122. package/dist/preferences.d.ts +44 -0
  123. package/dist/preferences.js +102 -0
  124. package/dist/primitive.d.ts +2 -0
  125. package/dist/primitive.js +11 -0
  126. package/dist/progress.d.ts +41 -0
  127. package/dist/progress.js +37 -0
  128. package/dist/radio.d.ts +164 -0
  129. package/dist/radio.js +145 -0
  130. package/dist/rating.d.ts +149 -0
  131. package/dist/rating.js +146 -0
  132. package/dist/renderless.d.ts +4 -0
  133. package/dist/renderless.js +28 -0
  134. package/dist/resizable.d.ts +54 -0
  135. package/dist/resizable.js +22 -0
  136. package/dist/scroll-area.d.ts +72 -0
  137. package/dist/scroll-area.js +77 -0
  138. package/dist/segmented-control.d.ts +151 -0
  139. package/dist/segmented-control.js +110 -0
  140. package/dist/segmented-input.d.ts +76 -0
  141. package/dist/segmented-input.js +115 -0
  142. package/dist/select.d.ts +458 -0
  143. package/dist/select.js +468 -0
  144. package/dist/separator.d.ts +14 -0
  145. package/dist/separator.js +8 -0
  146. package/dist/shortcuts.d.ts +32 -0
  147. package/dist/shortcuts.js +56 -0
  148. package/dist/slider.d.ts +65 -0
  149. package/dist/slider.js +194 -0
  150. package/dist/switch.d.ts +103 -0
  151. package/dist/switch.js +71 -0
  152. package/dist/tabs.d.ts +338 -0
  153. package/dist/tabs.js +27 -0
  154. package/dist/text-control.d.ts +89 -0
  155. package/dist/text-control.js +51 -0
  156. package/dist/text-match.d.ts +2 -0
  157. package/dist/text-match.js +7 -0
  158. package/dist/textarea.d.ts +106 -0
  159. package/dist/textarea.js +68 -0
  160. package/dist/time-input.d.ts +131 -0
  161. package/dist/time-input.js +32 -0
  162. package/dist/timeline.d.ts +81 -0
  163. package/dist/timeline.js +30 -0
  164. package/dist/toast-parts.d.ts +203 -0
  165. package/dist/toast-parts.js +270 -0
  166. package/dist/toast.d.ts +2 -0
  167. package/dist/toast.js +21 -0
  168. package/dist/toggle-props.d.ts +22 -0
  169. package/dist/toggle-props.js +14 -0
  170. package/dist/toggle.d.ts +199 -0
  171. package/dist/toggle.js +129 -0
  172. package/dist/token-input.d.ts +136 -0
  173. package/dist/token-input.js +214 -0
  174. package/dist/toolbar-context.d.ts +7 -0
  175. package/dist/toolbar-context.js +20 -0
  176. package/dist/toolbar.d.ts +120 -0
  177. package/dist/toolbar.js +77 -0
  178. package/dist/tooltip.d.ts +160 -0
  179. package/dist/tooltip.js +224 -0
  180. package/dist/tree.d.ts +300 -0
  181. package/dist/tree.js +209 -0
  182. package/dist/trigger-menu.d.ts +452 -0
  183. package/dist/trigger-menu.js +254 -0
  184. package/dist/use-primitive.d.ts +132 -0
  185. package/dist/use-primitive.js +462 -0
  186. package/dist/waterfall.d.ts +201 -0
  187. package/dist/waterfall.js +171 -0
  188. package/docs/README.md +89 -0
  189. package/docs/agents.md +1523 -0
  190. package/docs/components/accordion.md +1369 -0
  191. package/docs/components/alert-dialog.md +799 -0
  192. package/docs/components/autocomplete.md +1857 -0
  193. package/docs/components/avatar.md +272 -0
  194. package/docs/components/button.md +435 -0
  195. package/docs/components/calendar.md +1589 -0
  196. package/docs/components/carousel.md +1171 -0
  197. package/docs/components/checkbox.md +1008 -0
  198. package/docs/components/collapsible.md +536 -0
  199. package/docs/components/color-picker.md +706 -0
  200. package/docs/components/combobox.md +3504 -0
  201. package/docs/components/command.md +1481 -0
  202. package/docs/components/date-input.md +536 -0
  203. package/docs/components/date-picker.md +1244 -0
  204. package/docs/components/dialog.md +1397 -0
  205. package/docs/components/drawer.md +1166 -0
  206. package/docs/components/field.md +538 -0
  207. package/docs/components/file-input.md +611 -0
  208. package/docs/components/hover-card.md +505 -0
  209. package/docs/components/image-cropper.md +556 -0
  210. package/docs/components/input.md +306 -0
  211. package/docs/components/label.md +203 -0
  212. package/docs/components/listbox.md +1004 -0
  213. package/docs/components/menu.md +1229 -0
  214. package/docs/components/menubar.md +443 -0
  215. package/docs/components/meter.md +315 -0
  216. package/docs/components/navigation-menu.md +1523 -0
  217. package/docs/components/number-input.md +1029 -0
  218. package/docs/components/otp-input.md +512 -0
  219. package/docs/components/pagination.md +613 -0
  220. package/docs/components/password-input.md +649 -0
  221. package/docs/components/popover.md +1448 -0
  222. package/docs/components/preferences.md +208 -0
  223. package/docs/components/progress.md +423 -0
  224. package/docs/components/radio.md +785 -0
  225. package/docs/components/rating.md +416 -0
  226. package/docs/components/resizable.md +910 -0
  227. package/docs/components/scroll-area.md +915 -0
  228. package/docs/components/segmented-control.md +435 -0
  229. package/docs/components/select.md +2015 -0
  230. package/docs/components/separator.md +229 -0
  231. package/docs/components/slider.md +1084 -0
  232. package/docs/components/switch.md +565 -0
  233. package/docs/components/tabs.md +944 -0
  234. package/docs/components/textarea.md +299 -0
  235. package/docs/components/time-input.md +224 -0
  236. package/docs/components/timeline.md +654 -0
  237. package/docs/components/toast.md +1224 -0
  238. package/docs/components/toggle.md +500 -0
  239. package/docs/components/token-input.md +953 -0
  240. package/docs/components/toolbar.md +739 -0
  241. package/docs/components/tooltip.md +818 -0
  242. package/docs/components/tree.md +1306 -0
  243. package/docs/components/trigger-menu.md +1223 -0
  244. package/docs/components/waterfall.md +717 -0
  245. package/docs/controllers.md +71 -0
  246. package/docs/core.md +8027 -0
  247. package/docs/custom-parts.md +89 -0
  248. package/docs/first-component.md +83 -0
  249. package/docs/forms.md +122 -0
  250. package/docs/installation.md +72 -0
  251. package/docs/introduction.md +32 -0
  252. package/docs/lists-and-menus.md +122 -0
  253. package/docs/llms.txt +1502 -0
  254. package/docs/parts-and-composition.md +85 -0
  255. package/docs/popups.md +108 -0
  256. package/docs/rendering.md +56 -0
  257. package/docs/server-rendering.md +180 -0
  258. package/docs/state-and-events.md +100 -0
  259. package/docs/styling-and-animation.md +148 -0
  260. package/docs/utilities/async-options.md +348 -0
  261. package/docs/utilities/shortcuts.md +159 -0
  262. package/package.json +352 -3
@@ -0,0 +1,739 @@
1
+ # Toolbar
2
+
3
+ Give buttons, toggles, menus and fields one tab stop with arrow-key navigation.
4
+
5
+ Use a Toolbar to group the controls of an editor, a canvas or a table. Tab enters it once, and the arrow keys move between its buttons, toggles, menus and fields.
6
+
7
+ ```vue title="demo.vue"
8
+ <script setup lang="ts">
9
+ import { BoldIcon, ItalicIcon, LinkIcon, UnderlineIcon } from "@lucide/vue"
10
+ import { Toggle, ToggleIcon } from "@ui-sdk/vue/toggle"
11
+ import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
12
+ import { useLog } from "./log"
13
+
14
+ const styles = [
15
+ { label: "Bold", icon: BoldIcon },
16
+ { label: "Italic", icon: ItalicIcon },
17
+ { label: "Underline", icon: UnderlineIcon },
18
+ ]
19
+
20
+ const log = useLog()
21
+ </script>
22
+
23
+ <template>
24
+ <Toolbar aria-label="Formatting">
25
+ <Toggle
26
+ v-for="style in styles"
27
+ :key="style.label"
28
+ :aria-label="style.label"
29
+ @pressed-change="
30
+ (pressed) => log(`${style.label} ${pressed ? 'on' : 'off'}`)
31
+ "
32
+ >
33
+ <ToggleIcon>
34
+ <component :is="style.icon" />
35
+ </ToggleIcon>
36
+ </Toggle>
37
+ <ToolbarSeparator />
38
+ <ToolbarButton aria-label="Insert link" @click="log('Insert link')">
39
+ <LinkIcon aria-hidden="true" />
40
+ </ToolbarButton>
41
+ </Toolbar>
42
+ </template>
43
+ ```
44
+
45
+ Tab into the toolbar, then use Left and Right to move between Bold, Italic, Underline and Insert link. Press Space to toggle the focused style. The console logs each change.
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ npm install @ui-sdk/vue @ui-sdk/core
51
+ ```
52
+
53
+ ## Composition
54
+
55
+ Use the following composition to build a `Toolbar`:
56
+
57
+ ```text
58
+ Toolbar
59
+ ├── ToolbarButton
60
+ ├── ToolbarSeparator
61
+ ├── ToolbarGroup
62
+ │ ├── ToolbarButton
63
+ │ └── ToolbarButton
64
+ ├── ToolbarLink
65
+ └── ToolbarInput
66
+ ```
67
+
68
+ Put buttons, links and fields straight inside the toolbar. `ToolbarGroup` names a set of related items, and `ToolbarSeparator` draws a line between sets. Toggles and toggle groups join the toolbar on their own, and menu and select triggers join through `ToolbarButton`.
69
+
70
+ ## Usage
71
+
72
+ Import the parts and put them together:
73
+
74
+ ```vue
75
+ <script setup lang="ts">
76
+ import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
77
+ </script>
78
+
79
+ <template>
80
+ <Toolbar aria-label="Formatting">
81
+ <ToolbarButton>Undo</ToolbarButton>
82
+ <ToolbarButton>Redo</ToolbarButton>
83
+ <ToolbarSeparator />
84
+ <ToolbarButton>Insert Link</ToolbarButton>
85
+ </Toolbar>
86
+ </template>
87
+ ```
88
+
89
+ Name the toolbar with `aria-label`, and give every icon-only control its own.
90
+
91
+ ## Toggle Groups
92
+
93
+ A [Toggle](./toggle.md) group inside a toolbar joins its navigation instead of adding another tab stop. Arrow keys move focus without pressing anything; Enter or Space presses the focused toggle.
94
+
95
+ ```vue title="toggle-group.vue"
96
+ <script setup lang="ts">
97
+ import {
98
+ AlignCenterIcon,
99
+ AlignLeftIcon,
100
+ AlignRightIcon,
101
+ ListIcon,
102
+ ListOrderedIcon,
103
+ } from "@lucide/vue"
104
+ import { Toggle, ToggleGroup, ToggleIcon } from "@ui-sdk/vue/toggle"
105
+ import { Toolbar, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
106
+ import { useLog } from "./log"
107
+
108
+ const alignments = [
109
+ { value: "left", label: "Align left", icon: AlignLeftIcon },
110
+ { value: "center", label: "Align center", icon: AlignCenterIcon },
111
+ { value: "right", label: "Align right", icon: AlignRightIcon },
112
+ ]
113
+
114
+ const lists = [
115
+ { value: "bulleted", label: "Bulleted list", icon: ListIcon },
116
+ { value: "numbered", label: "Numbered list", icon: ListOrderedIcon },
117
+ ]
118
+
119
+ const log = useLog()
120
+ </script>
121
+
122
+ <template>
123
+ <Toolbar aria-label="Paragraph">
124
+ <ToggleGroup
125
+ :default-value="['left']"
126
+ :deselectable="false"
127
+ aria-label="Alignment"
128
+ @value-change="([value]) => log(`Align ${value}`)"
129
+ >
130
+ <Toggle v-for="item in alignments" :key="item.value" :value="item.value" :aria-label="item.label">
131
+ <ToggleIcon>
132
+ <component :is="item.icon" />
133
+ </ToggleIcon>
134
+ </Toggle>
135
+ </ToggleGroup>
136
+ <ToolbarSeparator />
137
+ <ToggleGroup
138
+ aria-label="List"
139
+ @value-change="
140
+ ([value]) =>
141
+ log(lists.find((list) => list.value === value)?.label ?? 'No list')
142
+ "
143
+ >
144
+ <Toggle v-for="item in lists" :key="item.value" :value="item.value" :aria-label="item.label">
145
+ <ToggleIcon>
146
+ <component :is="item.icon" />
147
+ </ToggleIcon>
148
+ </Toggle>
149
+ </ToggleGroup>
150
+ </Toolbar>
151
+ </template>
152
+ ```
153
+
154
+ Arrow from the alignment group to the list group, then press Space on Align center or Numbered list. The console logs each choice.
155
+
156
+ ## Groups
157
+
158
+ Use `ToolbarGroup` to name related controls. Set `disabled` on the group to disable them together; they stay focusable with `aria-disabled`.
159
+
160
+ ```vue title="group.vue"
161
+ <script setup lang="ts">
162
+ import {
163
+ ClipboardIcon,
164
+ CopyIcon,
165
+ RedoIcon,
166
+ ScissorsIcon,
167
+ UndoIcon,
168
+ } from "@lucide/vue"
169
+ import {
170
+ Toolbar,
171
+ ToolbarButton,
172
+ ToolbarGroup,
173
+ ToolbarSeparator,
174
+ } from "@ui-sdk/vue/toolbar"
175
+ import { useLog } from "./log"
176
+
177
+ const clipboard = [
178
+ { label: "Cut", icon: ScissorsIcon },
179
+ { label: "Copy", icon: CopyIcon },
180
+ { label: "Paste", icon: ClipboardIcon },
181
+ ]
182
+
183
+ const log = useLog()
184
+ </script>
185
+
186
+ <template>
187
+ <Toolbar aria-label="Edit">
188
+ <ToolbarGroup aria-label="Clipboard">
189
+ <ToolbarButton
190
+ v-for="item in clipboard"
191
+ :key="item.label"
192
+ :aria-label="item.label"
193
+ @click="log(item.label)"
194
+ >
195
+ <component :is="item.icon" aria-hidden="true" />
196
+ </ToolbarButton>
197
+ </ToolbarGroup>
198
+ <ToolbarSeparator />
199
+ <ToolbarGroup disabled aria-label="History">
200
+ <ToolbarButton aria-label="Undo">
201
+ <UndoIcon aria-hidden="true" />
202
+ </ToolbarButton>
203
+ <ToolbarButton aria-label="Redo">
204
+ <RedoIcon aria-hidden="true" />
205
+ </ToolbarButton>
206
+ </ToolbarGroup>
207
+ </Toolbar>
208
+ </template>
209
+ ```
210
+
211
+ Move through Cut, Copy and Paste into History with the arrow keys. Undo and Redo stay focusable but do nothing.
212
+
213
+ ## Menus
214
+
215
+ Render a [Menu](./menu.md) trigger through `ToolbarButton`'s `#render` slot. In a horizontal toolbar, Down opens the menu while Left and Right keep moving between toolbar items.
216
+
217
+ ```vue
218
+ <Menu>
219
+ <ToolbarButton>
220
+ <template #render="{ props }">
221
+ <MenuTrigger v-bind="props">Share</MenuTrigger>
222
+ </template>
223
+ </ToolbarButton>
224
+ <MenuContent>…</MenuContent>
225
+ </Menu>
226
+ ```
227
+
228
+ ```vue title="menu.vue"
229
+ <script setup lang="ts">
230
+ import { ChevronDownIcon } from "@lucide/vue"
231
+ import { Menu, MenuContent, MenuItem, MenuTrigger } from "@ui-sdk/vue/menu"
232
+ import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
233
+ import { useLog } from "./log"
234
+
235
+ const log = useLog()
236
+ </script>
237
+
238
+ <template>
239
+ <Toolbar aria-label="Document">
240
+ <ToolbarButton @click="log('Saved')">Save</ToolbarButton>
241
+ <Menu @action="(value) => log(`Shared by ${value}`)">
242
+ <ToolbarButton>
243
+ <template #render="{ props }">
244
+ <MenuTrigger v-bind="props">
245
+ Share
246
+ <ChevronDownIcon aria-hidden="true" />
247
+ </MenuTrigger>
248
+ </template>
249
+ </ToolbarButton>
250
+ <MenuContent>
251
+ <MenuItem value="email">Email</MenuItem>
252
+ <MenuItem value="link">Copy Link</MenuItem>
253
+ </MenuContent>
254
+ </Menu>
255
+ <ToolbarButton @click="log('Printed')">Print</ToolbarButton>
256
+ </Toolbar>
257
+ </template>
258
+ ```
259
+
260
+ Focus Share and press Down, then choose Email or Copy Link. Escape closes the menu and returns focus to Share.
261
+
262
+ ## Selects
263
+
264
+ A [Select](./select.md) trigger joins the same way. It keeps its select behavior while it takes part in the toolbar's focus order.
265
+
266
+ ```vue title="select.vue"
267
+ <script setup lang="ts">
268
+ import {
269
+ CheckIcon,
270
+ ChevronsUpDownIcon,
271
+ ZoomInIcon,
272
+ ZoomOutIcon,
273
+ } from "@lucide/vue"
274
+ import {
275
+ Select,
276
+ SelectContent,
277
+ SelectItem,
278
+ SelectItemIndicator,
279
+ SelectTrigger,
280
+ SelectValue,
281
+ } from "@ui-sdk/vue/select"
282
+ import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
283
+ import { computed, ref } from "vue"
284
+ import { useLog } from "./log"
285
+
286
+ const zooms = ["50%", "75%", "100%", "150%", "200%"]
287
+
288
+ const log = useLog()
289
+ const zoom = ref("100%")
290
+ const index = computed(() => zooms.indexOf(zoom.value))
291
+
292
+ function change(value: string) {
293
+ zoom.value = value
294
+ log(`Zoom ${value}`)
295
+ }
296
+ </script>
297
+
298
+ <template>
299
+ <Toolbar aria-label="View">
300
+ <ToolbarButton aria-label="Zoom out" :disabled="index === 0" @click="change(zooms[index - 1])">
301
+ <ZoomOutIcon aria-hidden="true" />
302
+ </ToolbarButton>
303
+ <Select :value="zoom" @value-change="(value) => value && change(value)">
304
+ <ToolbarButton aria-label="Zoom">
305
+ <template #render="{ props }">
306
+ <SelectTrigger v-bind="props">
307
+ <SelectValue />
308
+ <ChevronsUpDownIcon aria-hidden="true" />
309
+ </SelectTrigger>
310
+ </template>
311
+ </ToolbarButton>
312
+ <SelectContent>
313
+ <SelectItem v-for="zoom in zooms" :key="zoom" :value="zoom">
314
+ {{ zoom }}
315
+ <SelectItemIndicator>
316
+ <CheckIcon aria-hidden="true" />
317
+ </SelectItemIndicator>
318
+ </SelectItem>
319
+ </SelectContent>
320
+ </Select>
321
+ <ToolbarButton
322
+ aria-label="Zoom in"
323
+ :disabled="index === zooms.length - 1"
324
+ @click="change(zooms[index + 1])"
325
+ >
326
+ <ZoomInIcon aria-hidden="true" />
327
+ </ToolbarButton>
328
+ </Toolbar>
329
+ </template>
330
+ ```
331
+
332
+ Open Zoom and choose a value, or step it with Zoom out and Zoom in. Each button turns off at the end of the range.
333
+
334
+ ## Fields
335
+
336
+ Use `ToolbarInput` for a text field, or render another field through it, like a [Number Input](./number-input.md) control. A field keeps Home, End and the arrow keys while they move its caret. At the matching end, with no text selected, an arrow moves to the next item.
337
+
338
+ Entering a field with an arrow puts its caret at the far end in that direction: press the same arrow again to leave, or the other arrow to edit. A number input keeps Up and Down for stepping its value.
339
+
340
+ ```vue title="input.vue"
341
+ <script setup lang="ts">
342
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
343
+ import {
344
+ NumberInput,
345
+ NumberInputControl,
346
+ NumberInputDecrement,
347
+ NumberInputGroup,
348
+ NumberInputIncrement,
349
+ } from "@ui-sdk/vue/number-input"
350
+ import { Toolbar, ToolbarInput, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
351
+ </script>
352
+
353
+ <template>
354
+ <Toolbar aria-label="Text">
355
+ <NumberInput :default-value="14" :min="8" :max="72">
356
+ <NumberInputGroup>
357
+ <NumberInputDecrement aria-label="Decrease font size">
358
+ <MinusIcon aria-hidden="true" />
359
+ </NumberInputDecrement>
360
+ <ToolbarInput>
361
+ <template #render="{ props }">
362
+ <NumberInputControl v-bind="props" aria-label="Font size" />
363
+ </template>
364
+ </ToolbarInput>
365
+ <NumberInputIncrement aria-label="Increase font size">
366
+ <PlusIcon aria-hidden="true" />
367
+ </NumberInputIncrement>
368
+ </NumberInputGroup>
369
+ </NumberInput>
370
+ <ToolbarSeparator />
371
+ <ToolbarInput aria-label="Find" placeholder="Find…" />
372
+ </Toolbar>
373
+ </template>
374
+ ```
375
+
376
+ Move into Font size and press Up or Down to change it. In Find, type a word, then move the caret to an edge before that arrow leaves the field.
377
+
378
+ ## Links
379
+
380
+ `ToolbarLink` joins the same focus order and keeps its link behavior. The demo handles a plain click itself and leaves modified clicks, like opening in a new tab, to the browser.
381
+
382
+ ```vue title="link.vue"
383
+ <script setup lang="ts">
384
+ import { CheckIcon, MessageSquareIcon } from "@lucide/vue"
385
+ import {
386
+ Toolbar,
387
+ ToolbarButton,
388
+ ToolbarLink,
389
+ ToolbarSeparator,
390
+ } from "@ui-sdk/vue/toolbar"
391
+ import { useLog } from "./log"
392
+
393
+ const log = useLog()
394
+
395
+ function follow(event: MouseEvent) {
396
+ if (
397
+ event.button !== 0 ||
398
+ event.metaKey ||
399
+ event.ctrlKey ||
400
+ event.shiftKey ||
401
+ event.altKey
402
+ ) {
403
+ return
404
+ }
405
+ event.preventDefault()
406
+ log(`Opened ${(event.currentTarget as HTMLAnchorElement).textContent}`)
407
+ }
408
+ </script>
409
+
410
+ <template>
411
+ <Toolbar aria-label="Pull request">
412
+ <ToolbarButton aria-label="Approve" @click="log('Approved')">
413
+ <CheckIcon aria-hidden="true" />
414
+ </ToolbarButton>
415
+ <ToolbarButton aria-label="Comment" @click="log('Comment')">
416
+ <MessageSquareIcon aria-hidden="true" />
417
+ </ToolbarButton>
418
+ <ToolbarSeparator />
419
+ <ToolbarLink href="#files" @click="follow">Files Changed</ToolbarLink>
420
+ <ToolbarLink href="#checks" @click="follow">Checks</ToolbarLink>
421
+ </Toolbar>
422
+ </template>
423
+ ```
424
+
425
+ Arrow to Files Changed and press Enter. The console logs the page it opened.
426
+
427
+ ## Vertical
428
+
429
+ Set `orientation="vertical"` to move with Up and Down, like a canvas tool palette. Separators turn to run across the toolbar.
430
+
431
+ ```vue title="vertical.vue"
432
+ <script setup lang="ts">
433
+ import {
434
+ MousePointer2Icon,
435
+ PencilIcon,
436
+ SquareIcon,
437
+ Trash2Icon,
438
+ TypeIcon,
439
+ } from "@lucide/vue"
440
+ import { Toggle, ToggleGroup, ToggleIcon } from "@ui-sdk/vue/toggle"
441
+ import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
442
+ import { useLog } from "./log"
443
+
444
+ const tools = [
445
+ { value: "select", label: "Select", icon: MousePointer2Icon },
446
+ { value: "draw", label: "Draw", icon: PencilIcon },
447
+ { value: "shape", label: "Shape", icon: SquareIcon },
448
+ { value: "text", label: "Text", icon: TypeIcon },
449
+ ]
450
+
451
+ const log = useLog()
452
+ </script>
453
+
454
+ <template>
455
+ <Toolbar orientation="vertical" aria-label="Canvas">
456
+ <ToggleGroup
457
+ :default-value="['select']"
458
+ :deselectable="false"
459
+ orientation="vertical"
460
+ aria-label="Tool"
461
+ @value-change="
462
+ ([value]) =>
463
+ log(`${tools.find((tool) => tool.value === value)?.label} tool`)
464
+ "
465
+ >
466
+ <Toggle v-for="tool in tools" :key="tool.value" :value="tool.value" :aria-label="tool.label">
467
+ <ToggleIcon>
468
+ <component :is="tool.icon" />
469
+ </ToggleIcon>
470
+ </Toggle>
471
+ </ToggleGroup>
472
+ <ToolbarSeparator />
473
+ <ToolbarButton aria-label="Delete" @click="log('Deleted selection')">
474
+ <Trash2Icon aria-hidden="true" />
475
+ </ToolbarButton>
476
+ </Toolbar>
477
+ </template>
478
+ ```
479
+
480
+ Use Up and Down to move between the tools and Delete. Space picks the focused tool.
481
+
482
+ ## Disabled
483
+
484
+ A disabled item stays reachable with `aria-disabled`, so people can find it, but it ignores presses, including keys meant for a component rendered through it. Set `focusable-when-disabled` to `false` to skip it instead.
485
+
486
+ ```vue title="disabled.vue"
487
+ <script setup lang="ts">
488
+ import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
489
+ import { useLog } from "./log"
490
+
491
+ const log = useLog()
492
+ </script>
493
+
494
+ <template>
495
+ <Toolbar aria-label="Message">
496
+ <ToolbarButton @click="log('Reply')">Reply</ToolbarButton>
497
+ <ToolbarButton disabled @click="log('Archive')">Archive</ToolbarButton>
498
+ <ToolbarButton
499
+ disabled
500
+ :focusable-when-disabled="false"
501
+ @click="log('Delete')"
502
+ >Delete</ToolbarButton
503
+ >
504
+ </Toolbar>
505
+ </template>
506
+ ```
507
+
508
+ Arrow from Reply to Archive, which is disabled but focusable. Delete is skipped. Only Reply logs a press.
509
+
510
+ Set `disabled` on the toolbar to disable every item. The toolbar keeps its tab stop, and its fields can't be edited.
511
+
512
+ ```vue
513
+ <Toolbar disabled aria-label="Formatting">
514
+ <ToolbarButton>Bold</ToolbarButton>
515
+ <ToolbarInput aria-label="Find" />
516
+ </Toolbar>
517
+ ```
518
+
519
+ ## Loop
520
+
521
+ Arrow keys wrap from the last item to the first by default. Set `loop` to `false` to stop at the ends.
522
+
523
+ ```vue title="loop.vue"
524
+ <script setup lang="ts">
525
+ import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
526
+ import { useLog } from "./log"
527
+
528
+ const log = useLog()
529
+ </script>
530
+
531
+ <template>
532
+ <Toolbar :loop="false" aria-label="Pages">
533
+ <ToolbarButton
534
+ v-for="label in ['First', 'Previous', 'Next', 'Last']"
535
+ :key="label"
536
+ @click="log(`${label} page`)"
537
+ >
538
+ {{ label }}
539
+ </ToolbarButton>
540
+ </Toolbar>
541
+ </template>
542
+ ```
543
+
544
+ Focus Last and press Right. Focus stays there; Home still moves to First.
545
+
546
+ ## Controller
547
+
548
+ Create a controller with `createToolbarController` and pass it as `controller`. Its `focus()` moves focus to the item focused last, like the Alt+F10 shortcut editors give their toolbars. Create one controller per toolbar.
549
+
550
+ ```vue title="controller.vue"
551
+ <script setup lang="ts">
552
+ import { BoldIcon, ItalicIcon, LinkIcon } from "@lucide/vue"
553
+ import { useShortcut } from "@ui-sdk/vue/shortcuts"
554
+ import {
555
+ createToolbarController,
556
+ Toolbar,
557
+ ToolbarButton,
558
+ } from "@ui-sdk/vue/toolbar"
559
+ import { useLog } from "./log"
560
+
561
+ const actions = [
562
+ { label: "Bold", icon: BoldIcon },
563
+ { label: "Italic", icon: ItalicIcon },
564
+ { label: "Insert link", icon: LinkIcon },
565
+ ]
566
+
567
+ const log = useLog()
568
+ const toolbar = createToolbarController()
569
+ useShortcut("alt+f10", () => toolbar.focus(), { allowInInput: true })
570
+ </script>
571
+
572
+ <template>
573
+ <div data-slot="stack">
574
+ <div data-slot="controls">
575
+ <button type="button" @click="toolbar.focus()">Focus Toolbar</button>
576
+ </div>
577
+ <Toolbar :controller="toolbar" aria-label="Notes formatting">
578
+ <ToolbarButton
579
+ v-for="action in actions"
580
+ :key="action.label"
581
+ :aria-label="action.label"
582
+ @click="log(action.label)"
583
+ >
584
+ <component :is="action.icon" aria-hidden="true" />
585
+ </ToolbarButton>
586
+ </Toolbar>
587
+ <textarea aria-label="Notes" placeholder="Type, then press Alt+F10" />
588
+ </div>
589
+ </template>
590
+ ```
591
+
592
+ Type in Notes, then press Alt+F10 or choose Focus Toolbar. Press a toolbar button and the console logs it.
593
+
594
+ ## Custom Rendering
595
+
596
+ Render a component through `ToolbarButton` or `ToolbarInput` to combine their behavior, as the menu, select and number input examples do. A `#render` slot must bind the toolbar props onto the inner component with `v-bind`. [Parts and Composition](../parts-and-composition.md) explains the rendering contract.
597
+
598
+ ## Styling
599
+
600
+ Use `data-orientation` on the root for a row or a column, and on a separator for the way its line runs, across the toolbar. Use `data-disabled` to style unavailable items and groups. Toggles inside keep their own `data-pressed`.
601
+
602
+ Each part has a `data-slot`, such as `toolbar-button`, and its state attributes are listed under [Data Attributes](#data-attributes).
603
+
604
+ ## Data Attributes
605
+
606
+ ### Toolbar
607
+ `[data-slot="toolbar"]`
608
+
609
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
610
+ - `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
611
+
612
+ ### ToolbarButton
613
+ `[data-slot="toolbar-button"]`
614
+
615
+ - `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
616
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
617
+
618
+ ### ToolbarLink
619
+ `[data-slot="toolbar-link"]`
620
+
621
+ - `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
622
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
623
+
624
+ ### ToolbarInput
625
+ `[data-slot="toolbar-input"]`
626
+
627
+ - `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
628
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
629
+
630
+ ### ToolbarGroup
631
+ `[data-slot="toolbar-group"]`
632
+
633
+ - `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
634
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
635
+
636
+ ### ToolbarSeparator
637
+ `[data-slot="toolbar-separator"]`
638
+
639
+ - `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
640
+
641
+ ## API Reference
642
+
643
+ ### Toolbar
644
+
645
+ - `orientation?` (`ToolbarOrientation`): Which arrow keys move between items: left and right, or up and down.
646
+ - `loop?` (`boolean`): Whether arrow keys wrap from the last item to the first.
647
+ - `disabled?` (`boolean`): Stops every item from being used. Items stay focusable with `aria-disabled`, so the toolbar keeps its tab stop and stays discoverable.
648
+ - `controller?` (`{ focus: () => void; }`): Focuses the toolbar from anywhere. Create one with `createToolbarController()`.
649
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
650
+
651
+ ### ToolbarButton
652
+
653
+ - `disabled?` (`boolean`): Stops the item from being used. It stays focusable with `aria-disabled`, so arrow keys still reach it and a tooltip can say why.
654
+ - `focusableWhenDisabled?` (`boolean`): Whether a disabled item stays reachable with arrow keys. Turn it off to skip it, natively disabled.
655
+
656
+ ### ToolbarInput
657
+
658
+ - `disabled?` (`boolean`): Stops the item from being used. It stays focusable with `aria-disabled`, so arrow keys still reach it and a tooltip can say why.
659
+ - `focusableWhenDisabled?` (`boolean`): Whether a disabled item stays reachable with arrow keys. Turn it off to skip it, natively disabled.
660
+
661
+ ### ToolbarGroup
662
+
663
+ - `disabled?` (`boolean`): Disables every item in the group. They stay focusable with `aria-disabled`.
664
+
665
+ `ToolbarLink` and `ToolbarSeparator` take no props of their own.
666
+
667
+ ### State
668
+
669
+ What render slots receive on `ToolbarButton` and `ToolbarInput`, and the default slot on `ToolbarButton`:
670
+
671
+ - `disabled` (`boolean`): Whether the item is disabled, by itself, its group or the toolbar.
672
+ - `orientation` (`ToolbarOrientation`): The toolbar's `orientation` option: `"vertical"`, or `"horizontal"` for anything else.
673
+
674
+ On `ToolbarLink`:
675
+
676
+ - `disabled` (`boolean`): Whether the link is disabled, by its group or the toolbar.
677
+ - `orientation` (`ToolbarOrientation`): The toolbar's `orientation` option: `"vertical"`, or `"horizontal"` for anything else.
678
+
679
+ On `ToolbarSeparator`:
680
+
681
+ - `orientation` (`ToolbarOrientation`): Which way the line runs: across the toolbar, so vertical in a horizontal toolbar.
682
+
683
+ ### Controller
684
+
685
+ - `focus()` (`() => void`): Moves focus to the item that holds the toolbar's tab stop: the one focused last, or the first.
686
+
687
+ ## Accessibility
688
+
689
+ The toolbar follows the [WAI-ARIA toolbar pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/). The root has the `toolbar` role and `aria-orientation`, and separators have the `separator` role.
690
+
691
+ ### Keyboard
692
+
693
+ The toolbar has one tab stop, a roving focus. Tab enters on the first enabled item, then returns to the item focused last. The next Tab leaves the toolbar.
694
+
695
+ | Key | Action |
696
+ | -------------------------- | ----------------------------------------------- |
697
+ | `ArrowRight` / `ArrowLeft` | Move focus in a horizontal toolbar |
698
+ | `ArrowDown` / `ArrowUp` | Move focus in a vertical toolbar |
699
+ | `Home` / `End` | Focus the first or last item, except in a field |
700
+ | `Enter` / `Space` | Activate a button or toggle, or open its popup |
701
+
702
+ Controls keep the keys they use: Down opens a menu, and Up and Down step a number input. Moving focus never presses a toggle. In right-to-left text, Left and Right swap.
703
+
704
+ ### Tested Behavior
705
+
706
+ Every line below is an automated test.
707
+
708
+ - The toolbar is named and has a horizontal orientation.
709
+ - Tab lands on the first item, and Tab again leaves the toolbar.
710
+ - Shift+Tab from after the toolbar lands on its tab stop.
711
+ - ArrowRight moves through every item, into toggle groups and out of fields.
712
+ - ArrowRight on the last item wraps to the first, and ArrowLeft back.
713
+ - Arrow keys never press a toggle, and Space and Enter do.
714
+ - Tab comes back to the item focused last.
715
+ - A toggle group in the toolbar is no tab stop of its own.
716
+ - A disabled button stays reachable, says it's disabled and does nothing.
717
+ - A button runs its action when pressed.
718
+ - A menu trigger rendered through a button opens with ArrowDown, and arrows still move past it.
719
+ - Choosing from a menu in the toolbar returns focus to its trigger.
720
+ - A text field keeps Home and End for its caret.
721
+ - Up and Down step a number field in the toolbar.
722
+ - Separators run across the toolbar.
723
+ - A group of buttons is named.
724
+ - A link in the toolbar follows its href with Enter.
725
+ - With loop off, arrows stop at the ends.
726
+ - A disabled toolbar keeps one tab stop, and every item says it's disabled.
727
+
728
+ **Vertical**
729
+
730
+ - ArrowDown and ArrowUp move between items, and Left and Right don't.
731
+ - Separators run across a vertical toolbar.
732
+
733
+ **Disabled groups**
734
+
735
+ - Toggles and toggle groups in a disabled group are disabled.
736
+ - A link in a disabled group is disabled, and follows its href once enabled.
737
+ - Enabling a group enables the toggles and buttons in it.
738
+
739
+ Runs in React, Vue and web components.