@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,1448 @@
1
+ # Popover
2
+
3
+ Edit or explore something beside its trigger.
4
+
5
+ A popover keeps a small task close to the thing it belongs to. Put fields, buttons, or other interactive content inside; it handles placement, focus, and dismissal.
6
+
7
+ ```vue title="basic.vue"
8
+ <script setup lang="ts">
9
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
10
+ import { Input } from "@ui-sdk/vue/input"
11
+ import {
12
+ Popover,
13
+ PopoverClose,
14
+ PopoverContent,
15
+ PopoverDescription,
16
+ PopoverTitle,
17
+ PopoverTrigger,
18
+ } from "@ui-sdk/vue/popover"
19
+ </script>
20
+
21
+ <template>
22
+ <Popover>
23
+ <PopoverTrigger>Share</PopoverTrigger>
24
+ <PopoverContent>
25
+ <PopoverTitle>Share this document</PopoverTitle>
26
+ <PopoverDescription>Anyone with the link can view it.</PopoverDescription>
27
+ <Field>
28
+ <FieldLabel>Link</FieldLabel>
29
+ <Input readonly default-value="acme.app/d/q3-roadmap" />
30
+ </Field>
31
+ <div data-slot="row">
32
+ <PopoverClose>Cancel</PopoverClose>
33
+ <PopoverClose data-variant="solid">Copy Link</PopoverClose>
34
+ </div>
35
+ </PopoverContent>
36
+ </Popover>
37
+ </template>
38
+ ```
39
+
40
+ Press Share to open the popover, then close it with Cancel, Copy Link, Escape, or a press outside. Focus returns to Share.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ npm install @ui-sdk/vue @ui-sdk/core
46
+ ```
47
+
48
+ ## Composition
49
+
50
+ Use the following composition to build a `Popover`:
51
+
52
+ ```text
53
+ Popover
54
+ ├── PopoverTrigger
55
+ └── PopoverContent
56
+ ├── PopoverArrow
57
+ ├── PopoverTitle
58
+ ├── PopoverDescription
59
+ └── PopoverClose
60
+ ```
61
+
62
+ The content has the dialog role. Its title names it and its description adds context. The arrow is optional, and a popover can have several Close parts. The trigger can live inside the popover or [connect from elsewhere](#triggers-outside-the-popover).
63
+
64
+ ## Usage
65
+
66
+ Import the parts and put them together:
67
+
68
+ ```vue
69
+ <script setup lang="ts">
70
+ import {
71
+ Popover,
72
+ PopoverClose,
73
+ PopoverContent,
74
+ PopoverDescription,
75
+ PopoverTitle,
76
+ PopoverTrigger,
77
+ } from "@ui-sdk/vue/popover"
78
+ </script>
79
+
80
+ <template>
81
+ <Popover>
82
+ <PopoverTrigger>Share</PopoverTrigger>
83
+ <PopoverContent>
84
+ <PopoverTitle>Share this document</PopoverTitle>
85
+ <PopoverDescription>Anyone with the link can view it.</PopoverDescription>
86
+ <PopoverClose>Done</PopoverClose>
87
+ </PopoverContent>
88
+ </Popover>
89
+ </template>
90
+ ```
91
+
92
+ ## Forms
93
+
94
+ An ordinary form can save a value and then close the popover. Focus starts on the first field and returns to the trigger when the task finishes. A form with `method="dialog"` closes on submission and returns its submit button's value; the [row editor](#triggers-outside-the-popover) shows that version.
95
+
96
+ ```vue title="form.vue"
97
+ <script setup lang="ts">
98
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
99
+ import { Input } from "@ui-sdk/vue/input"
100
+ import {
101
+ Popover,
102
+ PopoverClose,
103
+ PopoverContent,
104
+ PopoverDescription,
105
+ PopoverTitle,
106
+ PopoverTrigger,
107
+ } from "@ui-sdk/vue/popover"
108
+ import { ref } from "vue"
109
+ import { useLog } from "./log"
110
+
111
+ const log = useLog()
112
+ const open = ref(false)
113
+
114
+ function onSubmit(event: Event) {
115
+ log(
116
+ `Saved ${new FormData(event.currentTarget as HTMLFormElement).get("name")}`
117
+ )
118
+ open.value = false
119
+ }
120
+ </script>
121
+
122
+ <template>
123
+ <Popover v-model:open="open">
124
+ <PopoverTrigger>Edit Profile</PopoverTrigger>
125
+ <PopoverContent>
126
+ <PopoverTitle>Edit profile</PopoverTitle>
127
+ <PopoverDescription>Your name shows on your posts.</PopoverDescription>
128
+ <form data-slot="stack" @submit.prevent="onSubmit">
129
+ <Field>
130
+ <FieldLabel>Name</FieldLabel>
131
+ <Input name="name" required default-value="Hollis Grant" />
132
+ </Field>
133
+ <div data-slot="row">
134
+ <PopoverClose>Cancel</PopoverClose>
135
+ <button type="submit" data-variant="solid">Save</button>
136
+ </div>
137
+ </form>
138
+ </PopoverContent>
139
+ </Popover>
140
+ </template>
141
+ ```
142
+
143
+ Open Edit Profile, change the name, and press Save. The popover closes and the console logs the saved name.
144
+
145
+ ## Keep It Open While Editing
146
+
147
+ Set `dismissible` to false while there is unsaved work. Escape and outside presses then keep the popover open and report `@dismiss-attempt`, so you can ask whether to discard it. Focus leaving is refused quietly. The trigger, Close parts, and controller can still close it.
148
+
149
+ ```vue title="draft.vue"
150
+ <script setup lang="ts">
151
+ import { Field, FieldControl, FieldLabel } from "@ui-sdk/vue/field"
152
+ import {
153
+ Popover,
154
+ PopoverClose,
155
+ PopoverContent,
156
+ PopoverDescription,
157
+ PopoverTitle,
158
+ PopoverTrigger,
159
+ } from "@ui-sdk/vue/popover"
160
+ import { ref } from "vue"
161
+ import { useLog } from "./log"
162
+
163
+ const log = useLog()
164
+ const open = ref(false)
165
+ const note = ref("")
166
+ const asking = ref(false)
167
+ let field: HTMLTextAreaElement | undefined
168
+
169
+ function close() {
170
+ open.value = false
171
+ note.value = ""
172
+ asking.value = false
173
+ }
174
+
175
+ function onInput(event: Event) {
176
+ field = event.target as HTMLTextAreaElement
177
+ note.value = field.value
178
+ }
179
+
180
+ function onDismissAttempt(details: { reason: string }) {
181
+ log(`Kept open (${details.reason})`)
182
+ asking.value = true
183
+ }
184
+
185
+ function keepEditing() {
186
+ asking.value = false
187
+ field?.focus()
188
+ }
189
+
190
+ function discard() {
191
+ log("Discarded the note")
192
+ close()
193
+ }
194
+
195
+ function save() {
196
+ log(note.value ? "Saved the note" : "Nothing to save")
197
+ close()
198
+ }
199
+ </script>
200
+
201
+ <template>
202
+ <Popover
203
+ :open="open"
204
+ :dismissible="note === ''"
205
+ @update:open="(next: boolean) => (next ? (open = true) : close())"
206
+ @dismiss-attempt="onDismissAttempt"
207
+ >
208
+ <PopoverTrigger>Add Note</PopoverTrigger>
209
+ <PopoverContent>
210
+ <PopoverTitle>Add a note</PopoverTitle>
211
+ <PopoverDescription>Only your team can see it.</PopoverDescription>
212
+ <Field>
213
+ <FieldLabel>Note</FieldLabel>
214
+ <FieldControl :value="note" @input="onInput">
215
+ <template #render="{ props }">
216
+ <textarea v-bind="props" placeholder="Call the printer about the proofs." />
217
+ </template>
218
+ </FieldControl>
219
+ </Field>
220
+ <div v-if="asking" data-slot="row" role="alert">
221
+ Discard your note?
222
+ <div data-slot="row">
223
+ <button type="button" data-size="sm" @click="keepEditing">
224
+ Keep Editing
225
+ </button>
226
+ <button type="button" data-size="sm" data-variant="solid" @click="discard">
227
+ Discard
228
+ </button>
229
+ </div>
230
+ </div>
231
+ <div v-else data-slot="row">
232
+ <PopoverClose>Cancel</PopoverClose>
233
+ <button type="button" data-variant="solid" @click="save">Save</button>
234
+ </div>
235
+ </PopoverContent>
236
+ </Popover>
237
+ </template>
238
+ ```
239
+
240
+ Open Add Note, type something, then press Escape or click outside. Keep Editing returns to the field; Discard closes the popover and clears the note.
241
+
242
+ ## Placement
243
+
244
+ `side` chooses an edge of the trigger, `bottom` by default, and `align` lines the popover up with its start, center, or end. Start and end follow text direction. The popover flips or shifts when the requested position doesn't fit, and `data-side` and `data-align` report where it landed. The [popup guide](../popups.md#place-the-content) covers the shared positioning options.
245
+
246
+ ```vue title="placement.vue"
247
+ <script setup lang="ts">
248
+ import { CheckIcon, ChevronDownIcon } from "@lucide/vue"
249
+ import {
250
+ Popover,
251
+ PopoverContent,
252
+ PopoverDescription,
253
+ PopoverTitle,
254
+ PopoverTrigger,
255
+ } from "@ui-sdk/vue/popover"
256
+ import {
257
+ Select,
258
+ SelectContent,
259
+ SelectItem,
260
+ SelectItemIndicator,
261
+ SelectLabel,
262
+ SelectTrigger,
263
+ SelectValue,
264
+ } from "@ui-sdk/vue/select"
265
+ import { ref } from "vue"
266
+
267
+ const sides = [
268
+ { value: "top", label: "Top" },
269
+ { value: "right", label: "Right" },
270
+ { value: "bottom", label: "Bottom" },
271
+ { value: "left", label: "Left" },
272
+ ]
273
+ const aligns = [
274
+ { value: "start", label: "Start" },
275
+ { value: "center", label: "Center" },
276
+ { value: "end", label: "End" },
277
+ ]
278
+ type Side = "top" | "right" | "bottom" | "left"
279
+ type Align = "start" | "center" | "end"
280
+
281
+ const side = ref<Side>("bottom")
282
+ const align = ref<Align>("center")
283
+ </script>
284
+
285
+ <template>
286
+ <div data-slot="stack">
287
+ <div data-slot="controls">
288
+ <Select
289
+ :items="sides"
290
+ :value="side"
291
+ @value-change="(next) => next && (side = next as Side)"
292
+ >
293
+ <SelectLabel>Side</SelectLabel>
294
+ <SelectTrigger>
295
+ <SelectValue />
296
+ <ChevronDownIcon aria-hidden="true" />
297
+ </SelectTrigger>
298
+ <SelectContent>
299
+ <SelectItem v-for="option in sides" :key="option.value" :value="option.value">
300
+ {{ option.label }}
301
+ <SelectItemIndicator>
302
+ <CheckIcon aria-hidden="true" />
303
+ </SelectItemIndicator>
304
+ </SelectItem>
305
+ </SelectContent>
306
+ </Select>
307
+ <Select
308
+ :items="aligns"
309
+ :value="align"
310
+ @value-change="(next) => next && (align = next as Align)"
311
+ >
312
+ <SelectLabel>Align</SelectLabel>
313
+ <SelectTrigger>
314
+ <SelectValue />
315
+ <ChevronDownIcon aria-hidden="true" />
316
+ </SelectTrigger>
317
+ <SelectContent>
318
+ <SelectItem v-for="option in aligns" :key="option.value" :value="option.value">
319
+ {{ option.label }}
320
+ <SelectItemIndicator>
321
+ <CheckIcon aria-hidden="true" />
322
+ </SelectItemIndicator>
323
+ </SelectItem>
324
+ </SelectContent>
325
+ </Select>
326
+ </div>
327
+ <Popover>
328
+ <PopoverTrigger>Delivery</PopoverTrigger>
329
+ <PopoverContent :side="side" :align="align" :side-offset="8">
330
+ <PopoverTitle>Delivery window</PopoverTitle>
331
+ <PopoverDescription
332
+ >Arrives Tuesday between 9 AM and noon.</PopoverDescription
333
+ >
334
+ </PopoverContent>
335
+ </Popover>
336
+ </div>
337
+ </template>
338
+ ```
339
+
340
+ Choose a side and an alignment, then open Delivery. Near a window edge, the popover flips or shifts to stay visible.
341
+
342
+ ## Offsets
343
+
344
+ `side-offset` is the gap to the trigger, 4 pixels by default. `align-offset` shifts the popover along the trigger's edge, and `collision-padding` is the space kept from the edges of the window.
345
+
346
+ ```vue title="offsets.vue"
347
+ <script setup lang="ts">
348
+ import { CheckIcon, ChevronDownIcon } from "@lucide/vue"
349
+ import {
350
+ Popover,
351
+ PopoverContent,
352
+ PopoverDescription,
353
+ PopoverTitle,
354
+ PopoverTrigger,
355
+ } from "@ui-sdk/vue/popover"
356
+ import {
357
+ Select,
358
+ SelectContent,
359
+ SelectItem,
360
+ SelectItemIndicator,
361
+ SelectLabel,
362
+ SelectTrigger,
363
+ SelectValue,
364
+ } from "@ui-sdk/vue/select"
365
+ import { reactive } from "vue"
366
+
367
+ const choices = {
368
+ sideOffset: { label: "Side offset", values: ["4", "8", "16", "24"] },
369
+ alignOffset: { label: "Align offset", values: ["-16", "0", "16"] },
370
+ collisionPadding: { label: "Collision padding", values: ["8", "24", "48"] },
371
+ }
372
+ type Name = keyof typeof choices
373
+
374
+ const offsets = reactive<Record<Name, string>>({
375
+ sideOffset: "8",
376
+ alignOffset: "0",
377
+ collisionPadding: "8",
378
+ })
379
+ </script>
380
+
381
+ <template>
382
+ <div data-slot="stack">
383
+ <div data-slot="controls">
384
+ <Select
385
+ v-for="(choice, name) in choices"
386
+ :key="name"
387
+ :items="choice.values"
388
+ :value="offsets[name]"
389
+ @value-change="(next) => next && (offsets[name] = next)"
390
+ >
391
+ <SelectLabel>{{ choice.label }}</SelectLabel>
392
+ <SelectTrigger>
393
+ <SelectValue />
394
+ <ChevronDownIcon aria-hidden="true" />
395
+ </SelectTrigger>
396
+ <SelectContent>
397
+ <SelectItem v-for="value in choice.values" :key="value" :value="value">
398
+ {{ value }}px
399
+ <SelectItemIndicator>
400
+ <CheckIcon aria-hidden="true" />
401
+ </SelectItemIndicator>
402
+ </SelectItem>
403
+ </SelectContent>
404
+ </Select>
405
+ </div>
406
+ <Popover>
407
+ <PopoverTrigger>Delivery</PopoverTrigger>
408
+ <PopoverContent
409
+ align="start"
410
+ :side-offset="Number(offsets.sideOffset)"
411
+ :align-offset="Number(offsets.alignOffset)"
412
+ :collision-padding="Number(offsets.collisionPadding)"
413
+ >
414
+ <PopoverTitle>Delivery window</PopoverTitle>
415
+ <PopoverDescription
416
+ >Arrives Tuesday between 9 AM and noon.</PopoverDescription
417
+ >
418
+ </PopoverContent>
419
+ </Popover>
420
+ </div>
421
+ </template>
422
+ ```
423
+
424
+ Change the offsets and the padding, then open Delivery. The popover moves away from the trigger and along it.
425
+
426
+ ## Arrow
427
+
428
+ `PopoverArrow` follows the side the popover actually uses, including after a flip, and gets the same `data-side`. `arrow-padding` keeps it away from the corners; `data-arrow-clamped` tells you when it can't point at the middle of the trigger. This example cancels dismissal when you press its side buttons, so the open arrow can move.
429
+
430
+ ```vue title="arrow.vue"
431
+ <script setup lang="ts">
432
+ import { CircleQuestionMarkIcon } from "@lucide/vue"
433
+ import type { ChangeDetails } from "@ui-sdk/core"
434
+ import {
435
+ Popover,
436
+ PopoverArrow,
437
+ PopoverContent,
438
+ PopoverDescription,
439
+ PopoverTitle,
440
+ PopoverTrigger,
441
+ } from "@ui-sdk/vue/popover"
442
+ import { ref } from "vue"
443
+
444
+ const sides = [
445
+ { value: "top", label: "Top" },
446
+ { value: "right", label: "Right" },
447
+ { value: "bottom", label: "Bottom" },
448
+ { value: "left", label: "Left" },
449
+ ] as const
450
+ type Side = (typeof sides)[number]["value"]
451
+
452
+ const open = ref(false)
453
+ const side = ref<Side>("bottom")
454
+ const controls = ref<HTMLElement | null>(null)
455
+
456
+ function onOpenChange(next: boolean, details: ChangeDetails) {
457
+ const target = details.event?.target
458
+ const inControls = target instanceof Node && controls.value?.contains(target)
459
+ if (inControls && details.reason !== "escape-key") {
460
+ return details.cancel()
461
+ }
462
+ open.value = next
463
+ }
464
+ </script>
465
+
466
+ <template>
467
+ <div data-slot="stack">
468
+ <div ref="controls" data-slot="controls" role="group" aria-label="Side">
469
+ <button
470
+ v-for="option in sides"
471
+ :key="option.value"
472
+ type="button"
473
+ data-size="sm"
474
+ :aria-pressed="side === option.value"
475
+ @click="side = option.value"
476
+ >
477
+ {{ option.label }}
478
+ </button>
479
+ </div>
480
+ <Popover :open="open" @open-change="onOpenChange">
481
+ <PopoverTrigger aria-label="Help">
482
+ <CircleQuestionMarkIcon aria-hidden="true" />
483
+ </PopoverTrigger>
484
+ <PopoverContent :side="side" :side-offset="10" :arrow-padding="12">
485
+ <PopoverArrow />
486
+ <PopoverTitle>Keyboard shortcuts</PopoverTitle>
487
+ <PopoverDescription
488
+ >Press ? anywhere to see them all.</PopoverDescription
489
+ >
490
+ </PopoverContent>
491
+ </Popover>
492
+ </div>
493
+ </template>
494
+ ```
495
+
496
+ Open Help, then press Top, Right, Bottom, or Left. The popover stays open while it and its arrow move to that side.
497
+
498
+ Keep overflow visible around an arrow that extends outside the panel. If the body needs to scroll, put scrolling on an inner element. You can also draw an arrow with `::before`, using `data-side` and `--arrow-offset` to position it.
499
+
500
+ ## Anchor
501
+
502
+ Set `anchor` to position against something other than the trigger. It accepts an element, a selector, a point such as `{ x, y }`, or an object with `getBoundingClientRect()`, such as a text range. The position is read again as the anchor moves.
503
+
504
+ ```vue title="anchor.vue"
505
+ <script setup lang="ts">
506
+ import { CheckIcon, SlidersHorizontalIcon } from "@lucide/vue"
507
+ import { Checkbox, CheckboxIndicator } from "@ui-sdk/vue/checkbox"
508
+ import {
509
+ Popover,
510
+ PopoverClose,
511
+ PopoverContent,
512
+ PopoverDescription,
513
+ PopoverTitle,
514
+ PopoverTrigger,
515
+ } from "@ui-sdk/vue/popover"
516
+ import { ref } from "vue"
517
+
518
+ const types = [
519
+ { label: "Documents", checked: true },
520
+ { label: "Images", checked: false },
521
+ { label: "Shared with me", checked: true },
522
+ ]
523
+
524
+ const anchor = ref<HTMLInputElement | null>(null)
525
+ </script>
526
+
527
+ <template>
528
+ <div data-slot="row">
529
+ <input ref="anchor" type="search" placeholder="Search files…" aria-label="Search files" />
530
+ <Popover>
531
+ <PopoverTrigger aria-label="Search filters">
532
+ <SlidersHorizontalIcon aria-hidden="true" />
533
+ </PopoverTrigger>
534
+ <PopoverContent :anchor="anchor" align="start" :side-offset="8">
535
+ <PopoverTitle>Filters</PopoverTitle>
536
+ <PopoverDescription>Show only these kinds of files.</PopoverDescription>
537
+ <div data-slot="stack">
538
+ <label v-for="type in types" :key="type.label" data-slot="label">
539
+ <Checkbox :default-checked="type.checked">
540
+ <CheckboxIndicator>
541
+ <CheckIcon aria-hidden="true" />
542
+ </CheckboxIndicator>
543
+ </Checkbox>
544
+ {{ type.label }}
545
+ </label>
546
+ </div>
547
+ <div data-slot="row">
548
+ <PopoverClose>Cancel</PopoverClose>
549
+ <PopoverClose data-variant="solid">Apply</PopoverClose>
550
+ </div>
551
+ </PopoverContent>
552
+ </Popover>
553
+ </div>
554
+ </template>
555
+ ```
556
+
557
+ Press the filters button. The popover lines up with the search field instead of the small button beside it.
558
+
559
+ ## Modal
560
+
561
+ `modal` controls how the popover shares the page:
562
+
563
+ - `false`, the default, leaves the page usable, and focus leaving the popover closes it.
564
+ - `"trap-focus"` keeps Tab inside while the page can still scroll and receive clicks.
565
+ - `true` also makes the rest of the page inert and locks scrolling.
566
+
567
+ ```vue title="modal.vue"
568
+ <script setup lang="ts">
569
+ import { CheckIcon, ChevronDownIcon } from "@lucide/vue"
570
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
571
+ import { Textarea } from "@ui-sdk/vue/textarea"
572
+ import {
573
+ Popover,
574
+ PopoverClose,
575
+ PopoverContent,
576
+ PopoverDescription,
577
+ PopoverTitle,
578
+ PopoverTrigger,
579
+ } from "@ui-sdk/vue/popover"
580
+ import {
581
+ Select,
582
+ SelectContent,
583
+ SelectItem,
584
+ SelectItemIndicator,
585
+ SelectLabel,
586
+ SelectTrigger,
587
+ SelectValue,
588
+ } from "@ui-sdk/vue/select"
589
+ import { computed, ref } from "vue"
590
+
591
+ const modes = [
592
+ { value: "false", label: "Non-modal" },
593
+ { value: "trap-focus", label: "Trap focus" },
594
+ { value: "true", label: "Modal" },
595
+ ]
596
+
597
+ type Mode = "false" | "trap-focus" | "true"
598
+
599
+ const notes = {
600
+ false: "Tab can leave, and focus leaving closes it.",
601
+ "trap-focus": "Tab stays inside. The page still scrolls and takes clicks.",
602
+ true: "Tab stays inside. The page is inert and doesn't scroll.",
603
+ }
604
+
605
+ const mode = ref<Mode>("false")
606
+ const modal = computed(() =>
607
+ mode.value === "true" ? true : mode.value === "false" ? false : "trap-focus"
608
+ )
609
+ </script>
610
+
611
+ <template>
612
+ <div data-slot="stack">
613
+ <div data-slot="controls">
614
+ <Select
615
+ :items="modes"
616
+ :value="mode"
617
+ @value-change="(next) => next && (mode = next as Mode)"
618
+ >
619
+ <SelectLabel>Modal</SelectLabel>
620
+ <SelectTrigger>
621
+ <SelectValue />
622
+ <ChevronDownIcon aria-hidden="true" />
623
+ </SelectTrigger>
624
+ <SelectContent>
625
+ <SelectItem v-for="option in modes" :key="option.value" :value="option.value">
626
+ {{ option.label }}
627
+ <SelectItemIndicator>
628
+ <CheckIcon aria-hidden="true" />
629
+ </SelectItemIndicator>
630
+ </SelectItem>
631
+ </SelectContent>
632
+ </Select>
633
+ </div>
634
+ <Popover :modal="modal">
635
+ <PopoverTrigger>Add Comment</PopoverTrigger>
636
+ <PopoverContent>
637
+ <PopoverTitle>Add a comment</PopoverTitle>
638
+ <PopoverDescription>{{ notes[mode] }}</PopoverDescription>
639
+ <Field>
640
+ <FieldLabel>Comment</FieldLabel>
641
+ <Textarea default-value="Looks good to me." />
642
+ </Field>
643
+ <div data-slot="row">
644
+ <PopoverClose>Cancel</PopoverClose>
645
+ <PopoverClose data-variant="solid">Comment</PopoverClose>
646
+ </div>
647
+ </PopoverContent>
648
+ </Popover>
649
+ </div>
650
+ </template>
651
+ ```
652
+
653
+ Choose a mode, open Add Comment, and try Tab or clicking the page.
654
+
655
+ ## Focus
656
+
657
+ Use `initial-focus` to choose the first focused element, or `"none"` to leave focus where it is. `final-focus` controls where focus returns. Opening on hover leaves focus alone; opening with touch focuses the panel itself so no on-screen keyboard appears. See [popup focus](../popups.md#focus) for the shared focus rules.
658
+
659
+ ```vue title="focus.vue"
660
+ <script setup lang="ts">
661
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
662
+ import { Input } from "@ui-sdk/vue/input"
663
+ import {
664
+ Popover,
665
+ PopoverClose,
666
+ PopoverContent,
667
+ PopoverDescription,
668
+ PopoverTitle,
669
+ PopoverTrigger,
670
+ } from "@ui-sdk/vue/popover"
671
+ </script>
672
+
673
+ <template>
674
+ <div data-slot="row">
675
+ <Popover>
676
+ <PopoverTrigger>Rename</PopoverTrigger>
677
+ <PopoverContent>
678
+ <PopoverTitle>Rename file</PopoverTitle>
679
+ <PopoverDescription
680
+ >Focus starts in the first field.</PopoverDescription
681
+ >
682
+ <Field>
683
+ <FieldLabel>Name</FieldLabel>
684
+ <Input default-value="Q3 roadmap.pdf" />
685
+ </Field>
686
+ <div data-slot="row">
687
+ <PopoverClose>Cancel</PopoverClose>
688
+ <PopoverClose data-variant="solid">Save</PopoverClose>
689
+ </div>
690
+ </PopoverContent>
691
+ </Popover>
692
+ <Popover>
693
+ <PopoverTrigger>Publish</PopoverTrigger>
694
+ <PopoverContent initial-focus="[data-autofocus]">
695
+ <PopoverTitle>Publish changes?</PopoverTitle>
696
+ <PopoverDescription
697
+ >Focus starts on Publish, not Cancel.</PopoverDescription
698
+ >
699
+ <div data-slot="row">
700
+ <PopoverClose>Cancel</PopoverClose>
701
+ <PopoverClose data-autofocus="" data-variant="solid"
702
+ >Publish</PopoverClose
703
+ >
704
+ </div>
705
+ </PopoverContent>
706
+ </Popover>
707
+ <Popover>
708
+ <PopoverTrigger>Status</PopoverTrigger>
709
+ <PopoverContent initial-focus="none" final-focus="none">
710
+ <PopoverTitle>All systems normal</PopoverTitle>
711
+ <PopoverDescription>Focus stays on the trigger.</PopoverDescription>
712
+ </PopoverContent>
713
+ </Popover>
714
+ </div>
715
+ </template>
716
+ ```
717
+
718
+ Open each one: Rename focuses its field, Publish focuses its Publish button, and Status leaves focus on the trigger.
719
+
720
+ ## Open on Hover
721
+
722
+ `open-on-hover` adds pointer opening while keeping click, keyboard, and touch activation. `delay` and `close-delay` control the pause before opening and closing. You can cross the gap into the content and interact with it.
723
+
724
+ ```vue title="hover.vue"
725
+ <script setup lang="ts">
726
+ import {
727
+ Popover,
728
+ PopoverArrow,
729
+ PopoverContent,
730
+ PopoverDescription,
731
+ PopoverTitle,
732
+ PopoverTrigger,
733
+ } from "@ui-sdk/vue/popover"
734
+ import { useLog } from "./log"
735
+
736
+ const log = useLog()
737
+ </script>
738
+
739
+ <template>
740
+ <Popover open-on-hover :delay="200" :close-delay="150">
741
+ <PopoverTrigger>@kofi</PopoverTrigger>
742
+ <PopoverContent :side-offset="8">
743
+ <PopoverArrow />
744
+ <PopoverTitle>Kofi Mensah</PopoverTitle>
745
+ <PopoverDescription
746
+ >Engineering manager, platform team.</PopoverDescription
747
+ >
748
+ <div data-slot="row">
749
+ <button type="button" data-size="sm" data-variant="solid" @click="log('Followed @kofi')">
750
+ Follow
751
+ </button>
752
+ </div>
753
+ </PopoverContent>
754
+ </Popover>
755
+ </template>
756
+ ```
757
+
758
+ Hover @kofi, then move into the popover and press Follow. You can also open it by pressing the trigger.
759
+
760
+ ## Controlled
761
+
762
+ Use `v-model:open` to keep the popover's state in your component. Cancel a proposed change with `details.cancel()` in `@open-change`. See [state and events](../state-and-events.md) for the common change contract.
763
+
764
+ ```vue title="controlled.vue"
765
+ <script setup lang="ts">
766
+ import { CheckIcon } from "@lucide/vue"
767
+ import type { ChangeDetails } from "@ui-sdk/core"
768
+ import { Checkbox, CheckboxIndicator } from "@ui-sdk/vue/checkbox"
769
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
770
+ import { Input } from "@ui-sdk/vue/input"
771
+ import {
772
+ Popover,
773
+ PopoverClose,
774
+ PopoverContent,
775
+ PopoverDescription,
776
+ PopoverTitle,
777
+ PopoverTrigger,
778
+ } from "@ui-sdk/vue/popover"
779
+ import { ref } from "vue"
780
+ import { useLog } from "./log"
781
+
782
+ const log = useLog()
783
+ const open = ref(false)
784
+ const controls = ref<HTMLElement | null>(null)
785
+
786
+ function onOpenChange(next: boolean, details: ChangeDetails) {
787
+ const target = details.event?.target
788
+ const inControls = target instanceof Node && controls.value?.contains(target)
789
+ if (inControls && details.reason !== "escape-key") {
790
+ return details.cancel()
791
+ }
792
+ log(`${next ? "Opened" : "Closed"} (${details.reason})`)
793
+ }
794
+ </script>
795
+
796
+ <template>
797
+ <div data-slot="stack">
798
+ <div ref="controls" data-slot="controls">
799
+ <label data-slot="label">
800
+ <Checkbox
801
+ :checked="open"
802
+ @checked-change="(next) => (open = next === true)"
803
+ >
804
+ <CheckboxIndicator>
805
+ <CheckIcon aria-hidden="true" />
806
+ </CheckboxIndicator>
807
+ </Checkbox>
808
+ Open
809
+ </label>
810
+ </div>
811
+ <Popover v-model:open="open" @open-change="onOpenChange">
812
+ <PopoverTrigger>Set Status</PopoverTrigger>
813
+ <PopoverContent>
814
+ <PopoverTitle>Set a status</PopoverTitle>
815
+ <PopoverDescription
816
+ >Your team sees it next to your name.</PopoverDescription
817
+ >
818
+ <Field>
819
+ <FieldLabel>Status</FieldLabel>
820
+ <Input default-value="In a meeting" />
821
+ </Field>
822
+ <div data-slot="row">
823
+ <PopoverClose>Cancel</PopoverClose>
824
+ <PopoverClose data-variant="solid">Save</PopoverClose>
825
+ </div>
826
+ </PopoverContent>
827
+ </Popover>
828
+ </div>
829
+ </template>
830
+ ```
831
+
832
+ Check Open or press Set Status, then close the popover. The console logs each change and its reason.
833
+
834
+ ## Keyboard Shortcut
835
+
836
+ Set a trigger's `shortcut` to toggle the popover from the keyboard. `mod+i` means Command+I on Apple platforms and Control+I elsewhere. The Shortcut part displays the platform's keys, and the trigger advertises them through `aria-keyshortcuts`.
837
+
838
+ ```vue title="shortcut.vue"
839
+ <script setup lang="ts">
840
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
841
+ import { Input } from "@ui-sdk/vue/input"
842
+ import {
843
+ Popover,
844
+ PopoverClose,
845
+ PopoverContent,
846
+ PopoverDescription,
847
+ PopoverShortcut,
848
+ PopoverTitle,
849
+ PopoverTrigger,
850
+ } from "@ui-sdk/vue/popover"
851
+ </script>
852
+
853
+ <template>
854
+ <Popover>
855
+ <PopoverTrigger shortcut="mod+i">
856
+ Invite
857
+ <PopoverShortcut />
858
+ </PopoverTrigger>
859
+ <PopoverContent>
860
+ <PopoverTitle>Invite people</PopoverTitle>
861
+ <PopoverDescription
862
+ >They'll get an email with a link to join.</PopoverDescription
863
+ >
864
+ <Field>
865
+ <FieldLabel>Email</FieldLabel>
866
+ <Input type="email" placeholder="wren@example.com" />
867
+ </Field>
868
+ <div data-slot="row">
869
+ <PopoverClose>Cancel</PopoverClose>
870
+ <PopoverClose data-variant="solid">Send Invite</PopoverClose>
871
+ </div>
872
+ </PopoverContent>
873
+ </Popover>
874
+ </template>
875
+ ```
876
+
877
+ Press Command+I or Control+I to open Invite. Press the same shortcut again, or Escape, to close it.
878
+
879
+ ## Triggers Outside the Popover
880
+
881
+ Connect the triggers and popover to one `createPopoverController<Member>()`. Each trigger passes its row as `payload`; the content reads the active row from its state. Only the active trigger is expanded and receives focus back. Opening from another row updates the same panel, so one editor can serve the whole list.
882
+
883
+ `controller.open({ payload, anchor })` opens it from code and returns a promise with the closing reason and any `returnValue`. The payload stays available during the exit animation. See [controllers](../controllers.md) for the shared pattern.
884
+
885
+ ```vue title="payload.vue"
886
+ <script setup lang="ts">
887
+ import { Field, FieldControl, FieldLabel } from "@ui-sdk/vue/field"
888
+ import {
889
+ createPopoverController,
890
+ Popover,
891
+ PopoverContent,
892
+ PopoverDescription,
893
+ PopoverTitle,
894
+ PopoverTrigger,
895
+ } from "@ui-sdk/vue/popover"
896
+ import { computed, ref } from "vue"
897
+ import { useLog } from "./log"
898
+
899
+ type Member = { name: string; role: string }
900
+
901
+ const roles = ["Admin", "Editor", "Viewer"]
902
+
903
+ const log = useLog()
904
+ const popover = createPopoverController<Member>()
905
+ const MemberPopoverContent = PopoverContent<Member>
906
+ const members = ref<Member[]>([
907
+ { name: "Hollis Grant", role: "Owner" },
908
+ { name: "Inès Moreau", role: "Editor" },
909
+ { name: "Kofi Mensah", role: "Viewer" },
910
+ { name: "Wren Takahashi", role: "Viewer" },
911
+ ])
912
+ const newest = computed(() => members.value[members.value.length - 1])
913
+
914
+ async function editNewest(event: MouseEvent) {
915
+ const result = await popover.open({
916
+ payload: newest.value,
917
+ anchor: event.currentTarget as HTMLElement,
918
+ })
919
+ log(`Closed (${result.reason}), returned ${result.returnValue ?? "nothing"}`)
920
+ }
921
+
922
+ function onPayloadChange(payload: unknown) {
923
+ const member = payload as Member | undefined
924
+ if (member) {
925
+ log(`Editing ${member.name}`)
926
+ }
927
+ }
928
+
929
+ function save(event: SubmitEvent, member: Member | undefined) {
930
+ if ((event.submitter as HTMLButtonElement).value !== "save" || !member) {
931
+ return
932
+ }
933
+ const role = String(
934
+ new FormData(event.currentTarget as HTMLFormElement).get("role")
935
+ )
936
+ members.value = members.value.map((entry) =>
937
+ entry.name === member.name ? { ...entry, role } : entry
938
+ )
939
+ }
940
+ </script>
941
+
942
+ <template>
943
+ <div data-slot="stack">
944
+ <div data-slot="controls">
945
+ <button type="button" @click="editNewest">Edit Newest Member</button>
946
+ </div>
947
+ <ul data-slot="list">
948
+ <li v-for="member in members" :key="member.name" data-slot="row">
949
+ {{ member.name }}
950
+ <span data-slot="hint">{{ member.role }}</span>
951
+ <PopoverTrigger
952
+ :controller="popover"
953
+ :payload="member"
954
+ :disabled="member.role === 'Owner'"
955
+ data-size="sm"
956
+ data-variant="ghost"
957
+ :aria-label="`Edit ${member.name}`"
958
+ >
959
+ Edit
960
+ </PopoverTrigger>
961
+ </li>
962
+ </ul>
963
+ <Popover :controller="popover" @payload-change="onPayloadChange">
964
+ <MemberPopoverContent v-slot="{ state }" align="end" :side-offset="8">
965
+ <PopoverTitle>{{ state.payload?.name }}</PopoverTitle>
966
+ <PopoverDescription
967
+ >Roles decide what they can change.</PopoverDescription
968
+ >
969
+ <form data-slot="stack" method="dialog" @submit="save($event as SubmitEvent, state.payload)">
970
+ <Field>
971
+ <FieldLabel>Role</FieldLabel>
972
+ <FieldControl :key="state.payload?.name" name="role" :default-value="state.payload?.role">
973
+ <template #render="{ props }">
974
+ <select v-bind="props">
975
+ <option v-for="role in roles" :key="role">{{ role }}</option>
976
+ </select>
977
+ </template>
978
+ </FieldControl>
979
+ </Field>
980
+ <div data-slot="row">
981
+ <button type="submit" value="cancel" formnovalidate>Cancel</button>
982
+ <button type="submit" value="save" data-variant="solid">
983
+ Save
984
+ </button>
985
+ </div>
986
+ </form>
987
+ </MemberPopoverContent>
988
+ </Popover>
989
+ </div>
990
+ </template>
991
+ ```
992
+
993
+ Edit Inès Moreau or Kofi Mensah and save a new role. The owner can't be edited. Edit Newest Member opens the same editor from code, and the console logs how it closed.
994
+
995
+ ## Animation
996
+
997
+ The content has `data-starting-style` while it opens and `data-ending-style` while it closes. Transition from those states, and the popover stays mounted until the exit finishes. `@open-change-complete` runs after the transition, and `keep-mounted` keeps the closed content in the page, hidden. See [styling and animation](../styling-and-animation.md) for the common lifecycle.
998
+
999
+ ```vue title="animation.vue"
1000
+ <script setup lang="ts">
1001
+ import {
1002
+ Popover,
1003
+ PopoverClose,
1004
+ PopoverContent,
1005
+ PopoverDescription,
1006
+ PopoverTitle,
1007
+ PopoverTrigger,
1008
+ } from "@ui-sdk/vue/popover"
1009
+ import { useLog } from "./log"
1010
+
1011
+ const log = useLog()
1012
+ </script>
1013
+
1014
+ <template>
1015
+ <Popover
1016
+ @open-change="(open: boolean) => log(open ? 'Opening' : 'Closing')"
1017
+ @open-change-complete="(open: boolean) => log(open ? 'Open' : 'Closed')"
1018
+ >
1019
+ <PopoverTrigger>What's New</PopoverTrigger>
1020
+ <PopoverContent keep-mounted>
1021
+ <PopoverTitle>What's new</PopoverTitle>
1022
+ <PopoverDescription
1023
+ >Comments now support threads and reactions.</PopoverDescription
1024
+ >
1025
+ <div data-slot="row">
1026
+ <PopoverClose data-variant="solid">Got It</PopoverClose>
1027
+ </div>
1028
+ </PopoverContent>
1029
+ </Popover>
1030
+ </template>
1031
+ ```
1032
+
1033
+ Open What's New, then press Got It. The console logs Opening, Open, Closing, and Closed.
1034
+
1035
+ ## Presentation
1036
+
1037
+ `presentation="sheet"` shows the task as a sheet; `"auto"` chooses a sheet on small touch screens each time it opens. A sheet is modal by default and can be swiped down to dismiss. If dismissal is disabled, it springs back and reports the attempt.
1038
+
1039
+ Style `data-presentation` for both layouts. The sheet manages its own position and movement, so leave its translation alone and avoid the floating panel's fixed width. `--sheet-backdrop` sets the dim behind it.
1040
+
1041
+ ```vue title="presentation.vue"
1042
+ <script setup lang="ts">
1043
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
1044
+ import { Input } from "@ui-sdk/vue/input"
1045
+ import {
1046
+ Popover,
1047
+ PopoverClose,
1048
+ PopoverContent,
1049
+ PopoverDescription,
1050
+ PopoverTitle,
1051
+ PopoverTrigger,
1052
+ } from "@ui-sdk/vue/popover"
1053
+ </script>
1054
+
1055
+ <template>
1056
+ <Popover presentation="sheet">
1057
+ <PopoverTrigger>Add Reminder</PopoverTrigger>
1058
+ <PopoverContent>
1059
+ <PopoverTitle>New reminder</PopoverTitle>
1060
+ <PopoverDescription
1061
+ >We'll notify you at the time you pick.</PopoverDescription
1062
+ >
1063
+ <Field>
1064
+ <FieldLabel>Remind me to</FieldLabel>
1065
+ <Input default-value="Send the Q3 roadmap" />
1066
+ </Field>
1067
+ <div data-slot="row">
1068
+ <PopoverClose>Cancel</PopoverClose>
1069
+ <PopoverClose data-variant="solid">Save</PopoverClose>
1070
+ </div>
1071
+ </PopoverContent>
1072
+ </Popover>
1073
+ </template>
1074
+ ```
1075
+
1076
+ Open Add Reminder as a sheet. Dismiss it with Cancel, Save, Escape, the dimmed area, or a downward swipe on a touch screen.
1077
+
1078
+ ## Container
1079
+
1080
+ Popovers render in place by default and use the browser's top layer. `container` moves their DOM to another element while keyboard order still follows the trigger. See [popups](../popups.md#mounting-and-containers) for the shared container behavior.
1081
+
1082
+ ```vue
1083
+ <script setup lang="ts">
1084
+ const container = useTemplateRef<HTMLDivElement>("container")
1085
+ </script>
1086
+
1087
+ <template>
1088
+ <div ref="container" />
1089
+ <Popover>
1090
+ <PopoverTrigger>Details</PopoverTrigger>
1091
+ <PopoverContent :container="container">...</PopoverContent>
1092
+ </Popover>
1093
+ </template>
1094
+ ```
1095
+
1096
+ ## Custom Rendering
1097
+
1098
+ Every part takes a `render` slot, which receives the props to bind and the part's state, and the default slot receives the state too. The content's default slot can read its payload, as the row editor does.
1099
+
1100
+ ```vue title="custom-rendering.vue"
1101
+ <script setup lang="ts">
1102
+ import {
1103
+ Popover,
1104
+ PopoverClose,
1105
+ PopoverContent,
1106
+ PopoverDescription,
1107
+ PopoverShortcut,
1108
+ PopoverTitle,
1109
+ PopoverTrigger,
1110
+ } from "@ui-sdk/vue/popover"
1111
+ </script>
1112
+
1113
+ <template>
1114
+ <Popover>
1115
+ <PopoverTrigger shortcut="mod+u">
1116
+ <template #render="{ props, state }">
1117
+ <button v-bind="props">
1118
+ {{ state.open ? "Hide Updates" : "Show Updates" }}
1119
+ <PopoverShortcut v-slot="{ state: shortcut }">{{
1120
+ shortcut.text
1121
+ }}</PopoverShortcut>
1122
+ </button>
1123
+ </template>
1124
+ </PopoverTrigger>
1125
+ <PopoverContent>
1126
+ <PopoverTitle>
1127
+ <template #render="{ props }">
1128
+ <h3 v-bind="props">Updates</h3>
1129
+ </template>
1130
+ </PopoverTitle>
1131
+ <PopoverDescription
1132
+ >Version 2.4 adds threaded comments.</PopoverDescription
1133
+ >
1134
+ <PopoverClose>
1135
+ <template #render="{ props }">
1136
+ <a v-bind="props" href="#">Read the Changelog</a>
1137
+ </template>
1138
+ </PopoverClose>
1139
+ </PopoverContent>
1140
+ </Popover>
1141
+ </template>
1142
+ ```
1143
+
1144
+ Open Show Updates. The trigger's label comes from its state, the title renders as an h3, and Close renders as a link.
1145
+
1146
+ ## Styling
1147
+
1148
+ Use `data-open` on the trigger to mark it while its popover shows, and `data-side` and `data-align` to style the content and arrow for where they landed. Put `transform-origin: var(--transform-origin)` on the content so a scale animation starts from the trigger.
1149
+
1150
+ Each part has a `data-slot`, such as `popover-content`, and its state attributes are listed under [Data Attributes](#data-attributes).
1151
+
1152
+ ### PopoverContent
1153
+ - `--anchor-width`: Width of the anchor, usually the trigger. Use it to match widths.
1154
+ - `--anchor-height`: Height of the anchor.
1155
+ - `--available-width`: Space beside the popup, up to the viewport edge. Not inherited either.
1156
+ - `--available-height`: Space between the anchor and the viewport edge. Use it for max-height. Not inherited, so a child that needs it copies it on the popup, like `[--list-height:var(--available-height)]`, and reads `max-h-(--list-height)`. The first popup registers both names for the whole page with `CSS.registerProperty`, so they don't inherit anywhere. A page that needs them to inherit calls it first, with `inherits: true`. An `@property` rule can't, since a registration in script wins.
1157
+ - `--transform-origin`: The point on the anchor the popup opens from. Use it to scale from the right place.
1158
+ - `--arrow-offset`: Where the anchor's center falls along the popup's edge, kept `arrowPadding` from the corners. Position a ::before arrow with it.
1159
+ - `--drawer-progress`: While it presents as a sheet: how far open the sheet is, from 0 closed to 1 at its largest snap point. Never past 1.
1160
+ - `--drawer-dim`: While it presents as a sheet: how dim the page behind is, from 0 to 1. The backdrop's opacity follows it.
1161
+ - `--drawer-expand`: While it presents as a sheet: 0 at the second-largest snap point and below, 1 at the largest. With one snap point, the whole travel.
1162
+ - `--drawer-stack`: While it presents as a sheet: how many sheets opened from inside this one are open above it, rising smoothly as each one opens. Push it back with it.
1163
+ - `--sheet-backdrop`: Set it yourself: the color the page dims to while it presents as a sheet. Black at 0.2 by default.
1164
+
1165
+ ### Viewport
1166
+ - `--keyboard-inset`: While it presents as a sheet: how many pixels of the page the on-screen keyboard covers, 0 without one.
1167
+ - `--visual-viewport-width`: While it presents as a sheet: the width of the part of the page you can see.
1168
+ - `--visual-viewport-height`: While it presents as a sheet: the height of the part of the page you can see, above the keyboard.
1169
+ - `--visual-viewport-top`: While it presents as a sheet: how far the part of the page you can see is scrolled from the top of the layout, as when the keyboard pushes it up.
1170
+
1171
+ ## Data Attributes
1172
+
1173
+ `PopoverTitle`, `PopoverDescription` and `PopoverClose` have no state attributes.
1174
+
1175
+ ### PopoverTrigger
1176
+ `[data-slot="popover-trigger"]`
1177
+
1178
+ - `data-closed`: Present while the popover is closed, including while it animates out.
1179
+ - `data-disabled`: Present when the trigger is disabled.
1180
+ - `data-open`: Present while the popover is open. On a trigger, while it's open from that trigger.
1181
+
1182
+ ### PopoverContent
1183
+ `[data-slot="popover-content"]`
1184
+
1185
+ - `data-closed`: Present while the popover is closed, including while it animates out.
1186
+ - `data-presentation` (`popover`, `sheet`): How the popover presents this time it's open.
1187
+ - `data-open`: Present while the popover is open. On a trigger, while it's open from that trigger.
1188
+ - `data-starting-style`: Present for the first frame. Style the state you animate from.
1189
+ - `data-ending-style`: Present while the popover animates out. Style the state you animate to.
1190
+
1191
+ ### PopoverArrow
1192
+ `[data-slot="popover-arrow"]`
1193
+
1194
+ - `data-closed`: Present while the popover is closed, including while it animates out.
1195
+ - `data-open`: Present while the popover is open. On a trigger, while it's open from that trigger.
1196
+
1197
+ ## API Reference
1198
+
1199
+ Props are the same as below, and callbacks are events.
1200
+
1201
+ ### Popover
1202
+
1203
+ - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
1204
+ - `open?` (`boolean`): Whether the popover is open. Pass it to control the popover.
1205
+ - `defaultOpen?` (`boolean`): Whether the popover starts open, when uncontrolled.
1206
+ - `@open-change` (`((open: boolean, details: ChangeDetails<PopoverOpenChangeReason>) => void)`): Runs when the popover wants to open or close. `details.reason` says why, and `details.cancel()` stops it.
1207
+ - `@open-change-complete` (`((open: boolean) => void)`): Runs once the popover has finished opening or closing, after any animation.
1208
+ - `@payload-change` (`((payload: unknown, details: ChangeDetails<PopoverPayloadChangeReason>) => void)`): Runs when the payload the content shows changes: a trigger with another payload opens the popover, or takes the open popover over, which fires no `@open-change`, and so does a controller's `open({ payload })` on the open popover. `details.cancel()` keeps the previous payload.
1209
+ - `modal?` (`"trap-focus" | boolean`): `false`: the rest of the page stays usable, and focus leaving the popover closes it. `true`: also traps focus, locks scroll and makes the rest of the page inert, and an outside press only closes the popover. `"trap-focus"`: traps focus but leaves the page scrollable and clickable.
1210
+ - `openOnHover?` (`boolean`): Whether resting the pointer on the trigger opens the popover. Pressing the trigger still opens it, so keyboard and touch users can too.
1211
+ - `delay?` (`number`): Milliseconds the pointer rests on the trigger before the popover opens, with `openOnHover`.
1212
+ - `closeDelay?` (`number`): Milliseconds before the popover closes once the pointer leaves it and its trigger, with `openOnHover`.
1213
+ - `presentation?` (`PresentationSetting<"popover">`): How the popover presents. `"sheet"` slides it up from the bottom of the screen, where it can be swiped away, and `"auto"` does that on small touch screens. Decided each time it opens; the server renders `"popover"` for `"auto"`.
1214
+ - `controller?` (`PopupController<any, PopoverOpenChangeReason, {}, string, PopoverPayloadChangeReason>`): Opens, closes and inspects the popover from anywhere, and connects triggers outside it. Create one with `createPopoverController()`.
1215
+ - `dismissible?` (`boolean`): Whether Escape, an outside press, focus or the window leaving, Android's back gesture and a sheet's swipe can close it. Triggers, Close parts and the controller always can. Pass `false` while it holds unsaved work, and ask in `@dismiss-attempt`.
1216
+ - `@dismiss-attempt` (`function`): Runs when `dismissible` refused a dismissal made on purpose: Escape, an outside press, back or a swipe. Focus or the window leaving is refused without it. Ask "Discard changes?" here.
1217
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
1218
+
1219
+ ### PopoverTrigger
1220
+
1221
+ A trigger outside the popover also takes `controller`.
1222
+
1223
+ - `disabled?` (`boolean`): Stops the trigger from opening the popover. A native button can't be focused or pressed, unless `focusableWhenDisabled` is set.
1224
+ - `focusableWhenDisabled?` (`boolean`): Keeps a disabled trigger in the tab order with `aria-disabled` instead of the native attribute, so it can host a tooltip that says why. Presses still do nothing.
1225
+ - `payload?` (`unknown`): Data for the content to render when this trigger opens the popover, like the row it belongs to.
1226
+ - `shortcut?` (`string`): A keyboard shortcut that presses the trigger, like `"mod+i"`. `mod` is Command on Apple platforms and Control elsewhere. Sets `aria-keyshortcuts`.
1227
+ - `controller?` (`PopupController<any, PopoverOpenChangeReason, {}, string, PopoverPayloadChangeReason>`): Connects a trigger outside the popover, like one per table row, to the popover with this controller.
1228
+
1229
+ ### PopoverContent
1230
+
1231
+ - `side?` (`Side`): Which side of the anchor the popup opens on. Flips to the other side when there isn't room. Which side of the trigger the popover opens on.
1232
+ - `align?` (`Align`): How the popup lines up with the anchor along that side. `start` and `end` follow the reading direction. How the popover lines up with the trigger along that side.
1233
+ - `sideOffset?` (`number`): Gap between the anchor and the popup, in pixels. Gap between the trigger and the popover, in pixels.
1234
+ - `alignOffset?` (`number`): Shift along the anchor, in pixels. Shift along the trigger, in pixels.
1235
+ - `collisionPadding?` (`number`): Space to keep from the viewport edges, in pixels.
1236
+ - `arrowPadding?` (`number`): Space to keep between the arrow and the popup's corners, in pixels.
1237
+ - `anchor?` (`string | Anchor | null`): Positions the popup against this instead of its trigger: an element, a CSS selector, a point like `{ x, y }`, or anything with `getBoundingClientRect()`. It's read on every check, so it can move. A controller's `open({ anchor })` wins for that open.
1238
+ - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
1239
+ - `initialFocus?` (`PopoverInitialFocus`): Where focus goes when the popover opens. Opening on hover never moves focus, and opening with touch focuses the popover itself so no on-screen keyboard appears.
1240
+ - `finalFocus?` (`PopupFocusTarget`): Where focus goes when the popover closes while focus is inside it.
1241
+ - `keepMounted?` (`boolean`): Whether the popover stays in the page, hidden, while closed. For animation libraries that drive the exit from state.
1242
+
1243
+ ### PopoverArrow
1244
+
1245
+ Points at the trigger from the side the popover landed on. Renders a `div`.
1246
+
1247
+ ### PopoverTitle
1248
+
1249
+ Names the popover. Renders an `h2`.
1250
+
1251
+ ### PopoverDescription
1252
+
1253
+ Describes the popover while it's rendered. Renders a `p`.
1254
+
1255
+ ### PopoverClose
1256
+
1257
+ Closes the popover. Renders a `button`.
1258
+
1259
+ ### PopoverShortcut
1260
+
1261
+ - `shortcut?` (`string`): The keys to show. Inside a trigger, its `shortcut`.
1262
+
1263
+ ### State
1264
+
1265
+ What render functions, state-based class names and slots receive, per part.
1266
+
1267
+ `PopoverTrigger`:
1268
+
1269
+ - `open` (`boolean`): Whether the popover is open from this trigger.
1270
+ - `disabled` (`boolean`): Set by the trigger's `disabled` prop, which stops it opening the popover.
1271
+
1272
+ `PopoverContent`:
1273
+
1274
+ - `open` (`boolean`): Whether the popover is open. False while it animates out.
1275
+ - `modal` (`boolean | "trap-focus"`): The `modal` setting.
1276
+ - `presentation` (`"popover" | "sheet"`): How it presents this time it's open.
1277
+ - `payload` (`Payload | undefined`): The payload of the last open, from the trigger that opened it or a controller, typed as the controller's `Payload`.
1278
+
1279
+ `PopoverArrow`:
1280
+
1281
+ - `open` (`boolean`): Whether the popover is open. False as soon as it starts closing, while it still animates out.
1282
+
1283
+ `PopoverShortcut`:
1284
+
1285
+ - `text` (`string`): The shortcut formatted for this platform: `⌘I` on Apple platforms and `Ctrl+I` elsewhere. Empty without one.
1286
+
1287
+ ### Reasons
1288
+
1289
+ `details.reason` says why the popover opened or closed.
1290
+
1291
+ - `trigger-press` (`MouseEvent | KeyboardEvent | TouchEvent`): Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its `touchend`.
1292
+ - `trigger-hover` (`PointerEvent`): The pointer rested on a trigger, or left it, with hover opening.
1293
+ - `outside-press` (`MouseEvent`): A press outside the layer.
1294
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1295
+ - `focus-out` (`KeyboardEvent | FocusEvent`): Focus left the layer, or Tab moved it out.
1296
+ - `window-blur` (`FocusEvent`): The window lost focus.
1297
+ - `close-press` (`MouseEvent | KeyboardEvent | SubmitEvent`): A Close part was pressed, or a form with `method="dialog"` was submitted.
1298
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
1299
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
1300
+ - `swipe` (`TouchEvent | PointerEvent`): A swipe gesture: a finger, mouse or pen dragged it.
1301
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1302
+
1303
+ For a payload change, it says what opened the popover or took it over.
1304
+
1305
+ - `trigger-press` (`MouseEvent | KeyboardEvent | TouchEvent`): Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its `touchend`.
1306
+ - `trigger-hover` (`PointerEvent`): The pointer rested on a trigger, or left it, with hover opening.
1307
+ - `shortcut` (`KeyboardEvent`): A keyboard shortcut, like a trigger's `shortcut`.
1308
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
1309
+
1310
+ With `dismissible` false, the refused dismissals `@dismiss-attempt` reports:
1311
+
1312
+ - `outside-press` (`MouseEvent`): A press outside the layer.
1313
+ - `escape-key` (`KeyboardEvent`): Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
1314
+ - `back` (`Event`): Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
1315
+ - `swipe` (`TouchEvent | PointerEvent`): A swipe gesture: a finger, mouse or pen dragged it.
1316
+
1317
+ ### Controller
1318
+
1319
+ Create one with `createPopoverController<Payload>()` and pass it as `controller`, to the popover and to any
1320
+ triggers outside it. `Payload` is the type of the data triggers and `open()` pass.
1321
+
1322
+ Every write method takes an optional `{ reason, event }`, passed to `@open-change`.
1323
+
1324
+ - `isOpen()` (`() => boolean`): Whether it's open. False as soon as it starts closing, while it still animates out.
1325
+ - `setOpen(open, options?)` (`(open: boolean, options?: PopupChangeOptions<PopoverOpenChangeReason> | undefined) => boolean`): Opens or closes it. Returns false when the change was canceled or it was already open or closed.
1326
+ - `open(options?)` (`(options?: (PopupChangeOptions<PopoverPayloadChangeReason> & { payload?: Payload | undefined; anchor?: Anchor | undefined; signal?: AbortSignal | undefined; }) | undefined) => Promise<...>`): Opens it, and resolves once it closes, with why, how and any return value. Resolves exactly once and never rejects: on the next close from any source, when `signal` aborts, or with reason `"unmount"` when the component leaves the page.
1327
+ - `close(options?)` (`(options?: (PopupChangeOptions<PopoverOpenChangeReason> & { returnValue?: Result | undefined; }) | undefined) => boolean`): Closes it. `returnValue` is passed to the promise `open()` returned. Returns false when the close was canceled or it was already closed.
1328
+ - `toggle(options?)` (`(options?: PopupChangeOptions<PopoverOpenChangeReason> | undefined) => boolean`): Opens it when it's closed, and closes it when it's open. Returns false when the change was canceled.
1329
+ - `getPayload()` (`() => Payload | undefined`): The payload of the last open, from a controller or the trigger that opened it.
1330
+ - `focus()` (`() => void`): Moves focus to the trigger that opened it last, or the first trigger.
1331
+
1332
+ ### Events
1333
+
1334
+ Events get the new state first, then the details. `v-model` only updates when `@open-change` wasn't canceled.
1335
+
1336
+ | Binding | On | Receives |
1337
+ | ----------------------- | --------- | --------------------------------------------------------------------------- |
1338
+ | `v-model:open` | `Popover` | Whether the popover is open |
1339
+ | `@open-change` | `Popover` | `(open, details)`: the new state, and the [reason](#reasons) |
1340
+ | `@open-change-complete` | `Popover` | `(open)`, after the animation |
1341
+ | `@payload-change` | `Popover` | `(payload, details)`: the content's new payload, and the [reason](#reasons) |
1342
+ | `@dismiss-attempt` | `Popover` | `({ reason, event })`, when a dismissal was refused |
1343
+
1344
+ ## Accessibility
1345
+
1346
+ The trigger is a button that opens a dialog, and focus inside follows the [WAI-ARIA dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
1347
+
1348
+ ### Tested Behavior
1349
+
1350
+ Every line below is an automated test.
1351
+
1352
+ **Trigger**
1353
+
1354
+ - Reflects the open state.
1355
+ - Click opens the popover.
1356
+ - Click on the open trigger closes the popover.
1357
+ - Enter opens the popover.
1358
+ - Space opens the popover.
1359
+ - Points to the popover it controls while open.
1360
+
1361
+ **Focus**
1362
+
1363
+ - Opening moves focus to the first focusable element.
1364
+ - Each time focus moves in, the popover is named by its title and described by its description.
1365
+ - Tab moves through the popover in order.
1366
+ - Shift+Tab from the first element returns focus to the trigger.
1367
+ - Tab from the last element moves focus to the element after the trigger.
1368
+ - Focus leaving the popover closes it.
1369
+ - Escape closes the popover and returns focus to the trigger.
1370
+ - Escape after a click returns focus to the trigger.
1371
+ - The close button closes the popover and returns focus to the trigger.
1372
+ - With initial focus none, opening leaves focus on the trigger.
1373
+ - A virtual click from a screen reader moves focus into the popover.
1374
+ - A touch press focuses the popover itself, so no on-screen keyboard appears.
1375
+ - Closing after the trigger is gone moves focus to the element after where it was.
1376
+ - Pressing a button inside keeps the popover open.
1377
+
1378
+ **Dismissal**
1379
+
1380
+ - Clicking outside closes the popover.
1381
+ - Clicking inside the popover keeps it open.
1382
+ - An outside press reaches what it hits.
1383
+ - A press on empty space returns focus to the trigger.
1384
+ - Escape while an input method is composing text leaves the popover open.
1385
+ - Pressing a scrollbar outside the popover leaves it open.
1386
+ - Pressing a button in a shadow root inside keeps the popover open.
1387
+ - Tab into a button in a shadow root inside keeps the popover open.
1388
+ - Escape on a button in a shadow root inside returns focus to the trigger.
1389
+ - Switching windows leaves the popover open.
1390
+
1391
+ **Modal**
1392
+
1393
+ - With modal true, Tab stays inside the popover.
1394
+ - With modal trap-focus, Tab stays inside the popover.
1395
+ - With modal true, an outside press only closes the popover.
1396
+ - With modal true, the page doesn't scroll while open.
1397
+
1398
+ **Hover**
1399
+
1400
+ - Resting the pointer on the trigger opens the popover.
1401
+ - Moving the pointer into the popover keeps it open.
1402
+ - Moving the pointer away closes the popover.
1403
+ - Opening on hover leaves focus where it was.
1404
+ - Keyboard focus on the trigger doesn't open the popover.
1405
+ - Escape on a popover opened by hover leaves focus where it was.
1406
+ - Pressing the trigger still opens the popover.
1407
+
1408
+ **Nested popovers**
1409
+
1410
+ - Using a nested popover keeps both open.
1411
+ - Escape closes only the nested popover and returns focus to its trigger.
1412
+ - Clicking outside closes every popover.
1413
+
1414
+ Runs in React, Vue and web components.
1415
+
1416
+ Additional behaviors:
1417
+
1418
+ **Enhancements**
1419
+
1420
+ - The popup writes --arrow-offset, where the trigger's center falls along its edge.
1421
+ - Without a title, the trigger names the popover.
1422
+ - Tab from the trigger of a popover opened by hover moves into it.
1423
+ - A controller opens the popover from anywhere and moves focus in.
1424
+ - A popover open from the start leaves focus alone.
1425
+ - Modal popovers make the rest of the page inert and restore it exactly.
1426
+ - Live regions keep announcing while a modal popover makes the page inert.
1427
+ - Clicking into an iframe closes the popover.
1428
+ - An infinite exit animation still unmounts.
1429
+
1430
+ **Shortcuts**
1431
+
1432
+ - A trigger's shortcut opens and closes the popover.
1433
+ - The trigger advertises its shortcut, and its Shortcut part shows the keys to sighted users only.
1434
+ - A Shortcut part shows its own keys.
1435
+ - A trigger connected through a controller shows and binds its own shortcut.
1436
+
1437
+ **Web components**
1438
+
1439
+ - A title added after the popover connects names it. Web components only.
1440
+ - Changing an attribute updates the part. Web components only.
1441
+
1442
+ Runs in React, Vue and web components.
1443
+
1444
+ Screen readers hear the same thing in each tested framework, recorded by a virtual screen reader:
1445
+
1446
+ - Announcements while using the popover with a keyboard.
1447
+
1448
+ Runs in React, Vue and web components.