@primevue/mcp 4.5.5 → 5.0.0-rc.2

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 (173) hide show
  1. package/LICENSE.md +45 -21
  2. package/README.md +48 -250
  3. package/data/components.json +47269 -0
  4. package/data/llms/components/accordion.md +629 -0
  5. package/data/llms/components/animateonscroll.md +165 -0
  6. package/data/llms/components/autocomplete.md +995 -0
  7. package/data/llms/components/avatar.md +264 -0
  8. package/data/llms/components/badge.md +200 -0
  9. package/data/llms/components/blockui.md +99 -0
  10. package/data/llms/components/breadcrumb.md +269 -0
  11. package/data/llms/components/button.md +902 -0
  12. package/data/llms/components/card.md +209 -0
  13. package/data/llms/components/carousel.md +506 -0
  14. package/data/llms/components/cascadeselect.md +1207 -0
  15. package/data/llms/components/chart.md +1022 -0
  16. package/data/llms/components/checkbox.md +401 -0
  17. package/data/llms/components/chip.md +206 -0
  18. package/data/llms/components/colorpicker.md +213 -0
  19. package/data/llms/components/commandmenu.md +660 -0
  20. package/data/llms/components/compare.md +407 -0
  21. package/data/llms/components/confirmdialog.md +343 -0
  22. package/data/llms/components/confirmpopup.md +252 -0
  23. package/data/llms/components/contextmenu.md +522 -0
  24. package/data/llms/components/datatable.md +5266 -0
  25. package/data/llms/components/dataview.md +569 -0
  26. package/data/llms/components/datepicker.md +964 -0
  27. package/data/llms/components/deferredcontent.md +96 -0
  28. package/data/llms/components/dialog.md +702 -0
  29. package/data/llms/components/divider.md +152 -0
  30. package/data/llms/components/dock.md +488 -0
  31. package/data/llms/components/drawer.md +469 -0
  32. package/data/llms/components/dynamicdialog.md +214 -0
  33. package/data/llms/components/editor.md +205 -0
  34. package/data/llms/components/fieldset.md +253 -0
  35. package/data/llms/components/fileupload.md +459 -0
  36. package/data/llms/components/floatlabel.md +144 -0
  37. package/data/llms/components/fluid.md +104 -0
  38. package/data/llms/components/focustrap.md +59 -0
  39. package/data/llms/components/forms.md +344 -0
  40. package/data/llms/components/galleria.md +1119 -0
  41. package/data/llms/components/gallery.md +1003 -0
  42. package/data/llms/components/iconfield.md +283 -0
  43. package/data/llms/components/iftalabel.md +96 -0
  44. package/data/llms/components/image.md +179 -0
  45. package/data/llms/components/imagecompare.md +108 -0
  46. package/data/llms/components/inplace.md +183 -0
  47. package/data/llms/components/inputcolor.md +869 -0
  48. package/data/llms/components/inputgroup.md +419 -0
  49. package/data/llms/components/inputmask.md +345 -0
  50. package/data/llms/components/inputnumber.md +551 -0
  51. package/data/llms/components/inputotp.md +345 -0
  52. package/data/llms/components/inputpassword.md +738 -0
  53. package/data/llms/components/inputtags.md +432 -0
  54. package/data/llms/components/inputtext.md +569 -0
  55. package/data/llms/components/installation.md +1 -0
  56. package/data/llms/components/keyfilter.md +116 -0
  57. package/data/llms/components/knob.md +318 -0
  58. package/data/llms/components/label.md +151 -0
  59. package/data/llms/components/laravel.md +53 -0
  60. package/data/llms/components/listbox.md +636 -0
  61. package/data/llms/components/mask.md +203 -0
  62. package/data/llms/components/mcp.md +39 -0
  63. package/data/llms/components/megamenu.md +563 -0
  64. package/data/llms/components/menu.md +651 -0
  65. package/data/llms/components/menubar.md +446 -0
  66. package/data/llms/components/message.md +497 -0
  67. package/data/llms/components/metergroup.md +281 -0
  68. package/data/llms/components/multiselect.md +752 -0
  69. package/data/llms/components/orderlist.md +224 -0
  70. package/data/llms/components/organizationchart.md +418 -0
  71. package/data/llms/components/paginator.md +221 -0
  72. package/data/llms/components/panel.md +321 -0
  73. package/data/llms/components/panelmenu.md +703 -0
  74. package/data/llms/components/password.md +657 -0
  75. package/data/llms/components/picklist.md +286 -0
  76. package/data/llms/components/popover.md +145 -0
  77. package/data/llms/components/progressbar.md +242 -0
  78. package/data/llms/components/progressspinner.md +104 -0
  79. package/data/llms/components/radiobutton.md +427 -0
  80. package/data/llms/components/rating.md +312 -0
  81. package/data/llms/components/ripple.md +91 -0
  82. package/data/llms/components/scrollarea.md +700 -0
  83. package/data/llms/components/scrollpanel.md +131 -0
  84. package/data/llms/components/scrolltop.md +87 -0
  85. package/data/llms/components/select.md +1251 -0
  86. package/data/llms/components/selectbutton.md +268 -0
  87. package/data/llms/components/sidebar.md +2232 -0
  88. package/data/llms/components/skeleton.md +302 -0
  89. package/data/llms/components/slider.md +416 -0
  90. package/data/llms/components/speeddial.md +402 -0
  91. package/data/llms/components/splitbutton.md +840 -0
  92. package/data/llms/components/splitter.md +447 -0
  93. package/data/llms/components/stepper.md +551 -0
  94. package/data/llms/components/styleclass.md +226 -0
  95. package/data/llms/components/tabs.md +609 -0
  96. package/data/llms/components/tag.md +178 -0
  97. package/data/llms/components/terminal.md +123 -0
  98. package/data/llms/components/textarea.md +519 -0
  99. package/data/llms/components/tieredmenu.md +578 -0
  100. package/data/llms/components/timeline.md +494 -0
  101. package/data/llms/components/toast.md +472 -0
  102. package/data/llms/components/togglebutton.md +276 -0
  103. package/data/llms/components/toggleswitch.md +271 -0
  104. package/data/llms/components/toolbar.md +140 -0
  105. package/data/llms/components/tooltip.md +160 -0
  106. package/data/llms/components/tree.md +1076 -0
  107. package/data/llms/components/treeselect.md +660 -0
  108. package/data/llms/components/treetable.md +2493 -0
  109. package/data/llms/components/virtualscroller.md +265 -0
  110. package/data/llms/guides/autoimport.md +28 -0
  111. package/data/llms/guides/cdn.md +72 -0
  112. package/data/llms/guides/configuration.md +158 -0
  113. package/data/llms/guides/customicons.md +67 -0
  114. package/data/llms/guides/guides/accessibility.md +27 -0
  115. package/data/llms/guides/guides/animations.md +119 -0
  116. package/data/llms/guides/guides/rtl.md +7 -0
  117. package/data/llms/guides/icons.md +136 -0
  118. package/data/llms/guides/installation.md +3 -0
  119. package/data/llms/guides/laravel.md +66 -0
  120. package/data/llms/guides/llms.md +15 -0
  121. package/data/llms/guides/mcp.md +104 -0
  122. package/data/llms/guides/migration/v4.md +15 -0
  123. package/data/llms/guides/migration/v5.md +15 -0
  124. package/data/llms/guides/nuxt.md +141 -0
  125. package/data/llms/guides/passthrough.md +137 -0
  126. package/data/llms/guides/primeclt.md +43 -0
  127. package/data/llms/guides/tailwind.md +151 -0
  128. package/data/llms/guides/theming/styled.md +497 -0
  129. package/data/llms/guides/theming/unstyled.md +57 -0
  130. package/data/llms/guides/uikit.md +3 -0
  131. package/data/llms/guides/vite.md +90 -0
  132. package/data/llms/llms-full.txt +54465 -0
  133. package/data/llms/llms.txt +132 -0
  134. package/data/llms/pages/accessibility.md +27 -0
  135. package/data/llms/pages/animations.md +119 -0
  136. package/data/llms/pages/autoimport.md +28 -0
  137. package/data/llms/pages/cdn.md +72 -0
  138. package/data/llms/pages/configuration.md +158 -0
  139. package/data/llms/pages/contribution.md +31 -0
  140. package/data/llms/pages/customicons.md +67 -0
  141. package/data/llms/pages/designer.md +79 -0
  142. package/data/llms/pages/dynamicimports.md +7 -0
  143. package/data/llms/pages/forms.md +63 -0
  144. package/data/llms/pages/guides/accessibility.md +27 -0
  145. package/data/llms/pages/guides/animations.md +119 -0
  146. package/data/llms/pages/guides/rtl.md +7 -0
  147. package/data/llms/pages/icons.md +136 -0
  148. package/data/llms/pages/installation.md +3 -0
  149. package/data/llms/pages/introduction.md +23 -0
  150. package/data/llms/pages/laravel.md +66 -0
  151. package/data/llms/pages/llms.md +15 -0
  152. package/data/llms/pages/mcp.md +104 -0
  153. package/data/llms/pages/migration/v4.md +15 -0
  154. package/data/llms/pages/migration/v5.md +15 -0
  155. package/data/llms/pages/nuxt.md +141 -0
  156. package/data/llms/pages/passthrough.md +137 -0
  157. package/data/llms/pages/primeclt.md +43 -0
  158. package/data/llms/pages/rtl.md +7 -0
  159. package/data/llms/pages/setup.md +3 -0
  160. package/data/llms/pages/styled.md +497 -0
  161. package/data/llms/pages/tailwind.md +151 -0
  162. package/data/llms/pages/theming/styled.md +497 -0
  163. package/data/llms/pages/theming/unstyled.md +57 -0
  164. package/data/llms/pages/uikit.md +3 -0
  165. package/data/llms/pages/unstyled.md +57 -0
  166. package/data/llms/pages/v4.md +15 -0
  167. package/data/llms/pages/v5.md +15 -0
  168. package/data/llms/pages/vite.md +90 -0
  169. package/data/manifest.json +11117 -0
  170. package/data/mcp-data.json +55940 -0
  171. package/dist/index.d.ts +17 -1
  172. package/dist/index.js +66066 -72541
  173. package/package.json +10 -12
@@ -0,0 +1,636 @@
1
+ # Listbox
2
+
3
+ Listbox is used to select one or more values from a list of items.
4
+
5
+ ## Basic
6
+
7
+ Listbox is used with the v-model property for two-way value binding along with the options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary.
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="flex justify-center">
12
+ <Listbox v-model="selectedCity" :options="cities" optionLabel="name" class="w-full md:w-56" />
13
+ </div>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref } from "vue";
18
+
19
+ const selectedCity = ref();
20
+ const cities = ref([
21
+ { name: 'New York', code: 'NY' },
22
+ { name: 'Rome', code: 'RM' },
23
+ { name: 'London', code: 'LDN' },
24
+ { name: 'Istanbul', code: 'IST' },
25
+ { name: 'Paris', code: 'PRS' }
26
+ ]);
27
+ <\/script>
28
+ ```
29
+
30
+ ## Option
31
+
32
+ For custom content support define an option slot where the default slot props refers to an option.
33
+
34
+ ```vue
35
+ <template>
36
+ <div class="flex justify-center">
37
+ <Listbox v-model="selectedCountry" :options="countries" optionLabel="name" class="w-full md:w-56">
38
+ <template #option="slotProps">
39
+ <div class="flex items-center gap-2">
40
+ <img :alt="slotProps.option.name" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()}\`" style="width: 18px" />
41
+ <div>{{ slotProps.option.name }}</div>
42
+ </div>
43
+ </template>
44
+ </Listbox>
45
+ </div>
46
+ </template>
47
+
48
+ <script setup>
49
+ import { ref } from 'vue';
50
+
51
+ const selectedCountry = ref();
52
+ const countries = ref([
53
+ { name: 'Australia', code: 'AU' },
54
+ { name: 'Brazil', code: 'BR' },
55
+ { name: 'China', code: 'CN' },
56
+ { name: 'Egypt', code: 'EG' },
57
+ { name: 'France', code: 'FR' },
58
+ { name: 'Germany', code: 'DE' },
59
+ { name: 'India', code: 'IN' },
60
+ { name: 'Japan', code: 'JP' },
61
+ { name: 'Spain', code: 'ES' },
62
+ { name: 'United States', code: 'US' }
63
+ ]);
64
+ <\/script>
65
+ ```
66
+
67
+ ## Checkmark
68
+
69
+ Enable the checkmark property to display a checkmark indicator next to the selected option. Set highlightOnSelect to false to use checkmark-only styling.
70
+
71
+ ```vue
72
+ <template>
73
+ <div class="flex justify-center">
74
+ <Listbox v-model="selectedCity" :options="cities" optionLabel="name" checkmark :highlightOnSelect="false" class="w-full md:w-56" />
75
+ </div>
76
+ </template>
77
+
78
+ <script setup>
79
+ import { ref } from "vue";
80
+
81
+ const selectedCity = ref();
82
+ const cities = ref([
83
+ { name: 'New York', code: 'NY' },
84
+ { name: 'Rome', code: 'RM' },
85
+ { name: 'London', code: 'LDN' },
86
+ { name: 'Istanbul', code: 'IST' },
87
+ { name: 'Paris', code: 'PRS' }
88
+ ]);
89
+ <\/script>
90
+ ```
91
+
92
+ ## Multiple
93
+
94
+ Listbox allows choosing a single item by default, enable multiple property to choose more than one. When the optional metaKeySelection is present, behavior is changed in a way that selecting a new item requires meta key to be present.
95
+
96
+ ```vue
97
+ <template>
98
+ <div class="flex justify-center">
99
+ <Listbox v-model="selectedCities" :options="cities" multiple :metaKeySelection="false" optionLabel="name" class="w-full md:w-56" />
100
+ </div>
101
+ </template>
102
+
103
+ <script setup>
104
+ import { ref } from 'vue';
105
+
106
+ const selectedCities = ref();
107
+ const cities = ref([
108
+ { name: 'New York', code: 'NY' },
109
+ { name: 'Rome', code: 'RM' },
110
+ { name: 'London', code: 'LDN' },
111
+ { name: 'Istanbul', code: 'IST' },
112
+ { name: 'Paris', code: 'PRS' }
113
+ ]);
114
+ <\/script>
115
+ ```
116
+
117
+ ## Meta Key Selection
118
+
119
+ Use metaKeySelection in multiple mode to require Ctrl / Cmd for additive selection.
120
+
121
+ ```vue
122
+ <template>
123
+ <div class="space-y-3">
124
+ <p class="text-sm text-muted-color text-center">Hold <kbd class="px-1 py-0.5 border rounded text-xs">Ctrl</kbd> (or <kbd class="px-1 py-0.5 border rounded text-xs">Cmd</kbd> on macOS) while selecting to keep existing selections.</p>
125
+ <div class="flex justify-center">
126
+ <Listbox v-model="selectedCities" :options="cities" multiple metaKeySelection optionLabel="name" class="w-full md:w-56" />
127
+ </div>
128
+ </div>
129
+ </template>
130
+
131
+ <script setup>
132
+ import { ref } from 'vue';
133
+
134
+ const selectedCities = ref();
135
+ const cities = ref([
136
+ { name: 'New York', code: 'NY' },
137
+ { name: 'Rome', code: 'RM' },
138
+ { name: 'London', code: 'LDN' },
139
+ { name: 'Istanbul', code: 'IST' },
140
+ { name: 'Paris', code: 'PRS' }
141
+ ]);
142
+ <\/script>
143
+ ```
144
+
145
+ ## Checkbox
146
+
147
+ Combine the multiple property with the checkbox property to render checkboxes for each option.
148
+
149
+ ```vue
150
+ <template>
151
+ <div class="flex justify-center">
152
+ <Listbox v-model="selectedCities" :options="cities" multiple checkbox optionLabel="name" class="w-full md:w-56" />
153
+ </div>
154
+ </template>
155
+
156
+ <script setup>
157
+ import { ref } from 'vue';
158
+
159
+ const selectedCities = ref();
160
+ const cities = ref([
161
+ { name: 'New York', code: 'NY' },
162
+ { name: 'Rome', code: 'RM' },
163
+ { name: 'London', code: 'LDN' },
164
+ { name: 'Istanbul', code: 'IST' },
165
+ { name: 'Paris', code: 'PRS' }
166
+ ]);
167
+ <\/script>
168
+ ```
169
+
170
+ ## Simple
171
+
172
+ Options can be grouped when a nested data structure is provided by defining optionGroupLabel and optionGroupChildren properties.
173
+
174
+ ```vue
175
+ <template>
176
+ <div class="flex justify-center">
177
+ <Listbox v-model="selectedCity" :options="groupedCities" optionLabel="label" optionValue="value" optionGroupLabel="label" optionGroupChildren="items" class="w-full md:w-56" scrollHeight="250px" />
178
+ </div>
179
+ </template>
180
+
181
+ <script setup>
182
+ import { ref } from 'vue';
183
+
184
+ const selectedCity = ref();
185
+ const groupedCities = ref([
186
+ {
187
+ label: 'Germany',
188
+ value: 'de',
189
+ items: [
190
+ { label: 'Berlin', value: 'Berlin' },
191
+ { label: 'Frankfurt', value: 'Frankfurt' },
192
+ { label: 'Hamburg', value: 'Hamburg' },
193
+ { label: 'Munich', value: 'Munich' }
194
+ ]
195
+ },
196
+ {
197
+ label: 'USA',
198
+ value: 'us',
199
+ items: [
200
+ { label: 'Chicago', value: 'Chicago' },
201
+ { label: 'Los Angeles', value: 'Los Angeles' },
202
+ { label: 'New York', value: 'New York' },
203
+ { label: 'San Francisco', value: 'San Francisco' }
204
+ ]
205
+ },
206
+ {
207
+ label: 'Japan',
208
+ value: 'jp',
209
+ items: [
210
+ { label: 'Kyoto', value: 'Kyoto' },
211
+ { label: 'Osaka', value: 'Osaka' },
212
+ { label: 'Tokyo', value: 'Tokyo' },
213
+ { label: 'Yokohama', value: 'Yokohama' }
214
+ ]
215
+ }
216
+ ]);
217
+ <\/script>
218
+ ```
219
+
220
+ ## Custom
221
+
222
+ Use the optiongroup slot to customize group headers with custom content like flags.
223
+
224
+ ```vue
225
+ <template>
226
+ <div class="flex justify-center">
227
+ <Listbox
228
+ v-model="selectedCity"
229
+ :options="groupedCities"
230
+ optionLabel="label"
231
+ optionValue="value"
232
+ optionGroupLabel="label"
233
+ optionGroupChildren="items"
234
+ class="w-full md:w-56"
235
+ scrollHeight="250px"
236
+ :pt="{ list: { class: 'p-0!' }, optionGroup: { class: 'border-b border-surface rounded-none' } }"
237
+ >
238
+ <template #optiongroup="slotProps">
239
+ <div class="flex items-center gap-2">
240
+ <span>{{ countryFlags[slotProps.option.value] }}</span>
241
+ <span>{{ slotProps.option.label }}</span>
242
+ </div>
243
+ </template>
244
+ </Listbox>
245
+ </div>
246
+ </template>
247
+
248
+ <script setup>
249
+ import { ref } from 'vue';
250
+
251
+ const selectedCity = ref();
252
+ const countryFlags = ref({
253
+ de: '🇩🇪',
254
+ us: '🇺🇸',
255
+ jp: '🇯🇵'
256
+ });
257
+ const groupedCities = ref([
258
+ {
259
+ label: 'Germany',
260
+ value: 'de',
261
+ items: [
262
+ { label: 'Berlin', value: 'Berlin' },
263
+ { label: 'Frankfurt', value: 'Frankfurt' },
264
+ { label: 'Hamburg', value: 'Hamburg' },
265
+ { label: 'Munich', value: 'Munich' }
266
+ ]
267
+ },
268
+ {
269
+ label: 'USA',
270
+ value: 'us',
271
+ items: [
272
+ { label: 'Chicago', value: 'Chicago' },
273
+ { label: 'Los Angeles', value: 'Los Angeles' },
274
+ { label: 'New York', value: 'New York' },
275
+ { label: 'San Francisco', value: 'San Francisco' }
276
+ ]
277
+ },
278
+ {
279
+ label: 'Japan',
280
+ value: 'jp',
281
+ items: [
282
+ { label: 'Kyoto', value: 'Kyoto' },
283
+ { label: 'Osaka', value: 'Osaka' },
284
+ { label: 'Tokyo', value: 'Tokyo' },
285
+ { label: 'Yokohama', value: 'Yokohama' }
286
+ ]
287
+ }
288
+ ]);
289
+ <\/script>
290
+ ```
291
+
292
+ ## Filter
293
+
294
+ Listbox provides built-in filtering that is enabled by adding the filter property.
295
+
296
+ ```vue
297
+ <template>
298
+ <div class="flex justify-center">
299
+ <Listbox v-model="selectedCity" :options="cities" filter optionLabel="name" filterPlaceholder="Search city" class="w-full md:w-56" />
300
+ </div>
301
+ </template>
302
+
303
+ <script setup>
304
+ import { ref } from "vue";
305
+
306
+ const selectedCity = ref();
307
+ const cities = ref([
308
+ { name: 'New York', code: 'NY' },
309
+ { name: 'Rome', code: 'RM' },
310
+ { name: 'London', code: 'LDN' },
311
+ { name: 'Istanbul', code: 'IST' },
312
+ { name: 'Paris', code: 'PRS' }
313
+ ]);
314
+ <\/script>
315
+ ```
316
+
317
+ ## Invalid
318
+
319
+ Invalid state is displayed using the invalid prop to indicate a failed validation. You can use this style when integrating with form validation libraries.
320
+
321
+ ```vue
322
+ <template>
323
+ <div class="flex justify-center">
324
+ <Listbox v-model="selectedCity" :options="cities" optionLabel="name" :invalid="selectedCity === null" class="w-full md:w-56" />
325
+ </div>
326
+ </template>
327
+
328
+ <script setup>
329
+ import { ref } from "vue";
330
+
331
+ const selectedCity = ref();
332
+ const cities = ref([
333
+ { name: 'New York', code: 'NY' },
334
+ { name: 'Rome', code: 'RM' },
335
+ { name: 'London', code: 'LDN' },
336
+ { name: 'Istanbul', code: 'IST' },
337
+ { name: 'Paris', code: 'PRS' }
338
+ ]);
339
+ <\/script>
340
+ ```
341
+
342
+ ## Disabled
343
+
344
+ When disabled is present, the element cannot be edited and focused.
345
+
346
+ ```vue
347
+ <template>
348
+ <div class="flex justify-center">
349
+ <Listbox v-model="selectedCity" disabled :options="cities" optionLabel="name" class="w-full md:w-56" />
350
+ </div>
351
+ </template>
352
+
353
+ <script setup>
354
+ import { ref } from "vue";
355
+
356
+ const selectedCity = ref();
357
+ const cities = ref([
358
+ { name: 'New York', code: 'NY' },
359
+ { name: 'Rome', code: 'RM' },
360
+ { name: 'London', code: 'LDN' },
361
+ { name: 'Istanbul', code: 'IST' },
362
+ { name: 'Paris', code: 'PRS' }
363
+ ]);
364
+ <\/script>
365
+ ```
366
+
367
+ ## Disabled Options
368
+
369
+ Use optionDisabled to disable specific items by field name while keeping the listbox itself interactive.
370
+
371
+ ```vue
372
+ <template>
373
+ <div class="flex justify-center">
374
+ <Listbox v-model="selectedCity" :options="cities" optionLabel="name" optionDisabled="disabled" class="w-full md:w-56" />
375
+ </div>
376
+ </template>
377
+
378
+ <script setup>
379
+ import { ref } from 'vue';
380
+
381
+ const selectedCity = ref();
382
+ const cities = ref([
383
+ { name: 'New York', code: 'NY' },
384
+ { name: 'Rome', code: 'RM' },
385
+ { name: 'London', code: 'LDN', disabled: true },
386
+ { name: 'Istanbul', code: 'IST' },
387
+ { name: 'Paris', code: 'PRS', disabled: true }
388
+ ]);
389
+ <\/script>
390
+ ```
391
+
392
+ ## Focus Behavior
393
+
394
+ Use autoOptionFocus to control initial focused option behavior, selectOnFocus to select options while navigating with focus, and focusOnHover to move focus with mouse hover when the component is focused.
395
+
396
+ ```vue
397
+ <template>
398
+ <div class="space-y-4">
399
+ <div class="flex flex-wrap gap-2 justify-center">
400
+ <Button :severity="autoOptionFocus ? 'primary' : 'secondary'" size="small" @click="autoOptionFocus = !autoOptionFocus">{{ \`autoOptionFocus: \${autoOptionFocus}\` }}</Button>
401
+ <Button :severity="selectOnFocus ? 'primary' : 'secondary'" size="small" @click="selectOnFocus = !selectOnFocus">{{ \`selectOnFocus: \${selectOnFocus}\` }}</Button>
402
+ <Button :severity="focusOnHover ? 'primary' : 'secondary'" size="small" @click="focusOnHover = !focusOnHover">{{ \`focusOnHover: \${focusOnHover}\` }}</Button>
403
+ </div>
404
+ <div class="flex justify-center">
405
+ <Listbox v-model="selectedCity" :options="cities" optionLabel="name" optionValue="code" :autoOptionFocus="autoOptionFocus" :selectOnFocus="selectOnFocus" :focusOnHover="focusOnHover" class="w-full md:w-56" />
406
+ </div>
407
+ </div>
408
+ </template>
409
+
410
+ <script setup>
411
+ import { ref } from 'vue';
412
+
413
+ const selectedCity = ref();
414
+ const autoOptionFocus = ref(true);
415
+ const selectOnFocus = ref(false);
416
+ const focusOnHover = ref(true);
417
+ const cities = ref([
418
+ { name: 'New York', code: 'NY' },
419
+ { name: 'Rome', code: 'RM' },
420
+ { name: 'London', code: 'LDN' },
421
+ { name: 'Istanbul', code: 'IST' },
422
+ { name: 'Paris', code: 'PRS' }
423
+ ]);
424
+ <\/script>
425
+ ```
426
+
427
+ ## Virtual Scroll
428
+
429
+ VirtualScroller is used to render a long list of options efficiently like 100K records in this demo. The configuration is done with virtualScrollerOptions property, refer to the VirtualScroller for more information about the available options as it is used internally by Listbox.
430
+
431
+ ```vue
432
+ <template>
433
+ <div class="flex justify-center">
434
+ <Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 38 }" class="w-full md:w-56" listStyle="height:250px" striped />
435
+ </div>
436
+ </template>
437
+
438
+ <script setup>
439
+ import { ref } from "vue";
440
+
441
+ const selectedItem = ref();
442
+ const items = ref(Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i })));
443
+ <\/script>
444
+ ```
445
+
446
+ ## Forms
447
+
448
+ Listbox integrates seamlessly with the PrimeVue Forms library.
449
+
450
+ ```vue
451
+ <template>
452
+ <div class="flex justify-center">
453
+ <Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full sm:w-56">
454
+ <div class="flex flex-col gap-1">
455
+ <Listbox name="city" :options="cities" optionLabel="name" fluid />
456
+ <Message v-if="$form.city?.invalid" severity="error" size="small" variant="simple">{{ $form.city.error?.message }}</Message>
457
+ </div>
458
+ <Button type="submit" severity="secondary">Submit</Button>
459
+ </Form>
460
+ </div>
461
+ </template>
462
+
463
+ <script setup>
464
+ import { ref } from 'vue';
465
+ import { zodResolver } from '@primevue/forms/resolvers/zod';
466
+ import { useToast } from "primevue/usetoast";
467
+ import { z } from 'zod';
468
+
469
+ const toast = useToast();
470
+ const initialValues = ref({
471
+ city: { name: '' }
472
+ });
473
+ const resolver = ref(zodResolver(
474
+ z.object({
475
+ city: z.union([
476
+ z.object({
477
+ name: z.string().min(1, 'City is required.')
478
+ }),
479
+ z.any().refine((val) => false, { message: 'City is required.' })
480
+ ])
481
+ })
482
+ ));
483
+
484
+ const onFormSubmit = ({ valid }) => {
485
+ if (valid) {
486
+ toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 });
487
+ }
488
+ };
489
+ <\/script>
490
+ ```
491
+
492
+ ## Accessibility
493
+
494
+ Screen Reader Value to describe the component can be provided aria-labelledby or aria-label props. The list element has a listbox role with the aria-multiselectable attribute that sets to true when multiple selection is enabled. Each list item has an option role with aria-selected and aria-disabled as their attributes. If filtering is enabled, filterInputProps can be defined to give aria-* props to the input element. Alternatively filterPlaceholder is usually utilized by the screen readers as well. Keyboard Support Key Function tab Moves focus to the first selected option, if there is none then first option receives the focus. up arrow Moves focus to the previous option. down arrow Moves focus to the next option. enter Toggles the selected state of the focused option. space Toggles the selected state of the focused option. home Moves focus to the first option. end Moves focus to the last option. shift + down arrow Moves focus to the next option and toggles the selection state. shift + up arrow Moves focus to the previous option and toggles the selection state. shift + space Selects the items between the most recently selected option and the focused option. control + shift + home Selects the focused options and all the options up to the first one. control + shift + end Selects the focused options and all the options down to the last one. control + a Selects all options. pageUp Jumps visual focus to first option. pageDown Jumps visual focus to last option. any printable character Moves focus to the option whose label starts with the characters being typed. Filter Input Keyboard Support Key Function down arrow Moves focus to the next option, if there is none then visual focus does not change. up arrow Moves focus to the previous option, if there is none then visual focus does not change. left arrow Removes the visual focus from the current option and moves input cursor to one character left. right arrow Removes the visual focus from the current option and moves input cursor to one character right. home Moves input cursor at the end, if not then moves focus to the first option. end Moves input cursor at the beginning, if not then moves focus to the last option. enter Closes the popup and moves focus to the multiselect element. escape Closes the popup and moves focus to the multiselect element. tab Moves focus to the next focusable element in the component. If there is none, moves focus to next element in page.
495
+
496
+ ```vue
497
+ <span id="lb">Options</span>
498
+ <Listbox aria-labelledby="lb" />
499
+
500
+ <Listbox aria-label="City" />
501
+ ```
502
+
503
+ ## Listbox API
504
+
505
+ ### Props
506
+
507
+ | Name |Type |Default |Description |
508
+ | --- | --- | --- | --- |
509
+ | modelValue | any | - | Value of the component. |
510
+ | defaultValue | any | - | The default value for the input when not controlled by `modelValue` . |
511
+ | name | string | - | The name attribute for the element, typically used in form submissions. |
512
+ | options | any[] | - | An array of selectitems to display as the available options. |
513
+ | optionLabel | string \| Function | - | Property name or getter function to use as the label of an option. |
514
+ | optionValue | string \| Function | - | Property name or getter function to use as the value of an option, defaults to the option itself when not defined. |
515
+ | optionDisabled | string \| Function | - | Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. |
516
+ | optionGroupLabel | string \| Function | - | Property name or getter function to use as the label of an option group. |
517
+ | optionGroupChildren | string \| Function | - | Property name or getter function that refers to the children options of option group. |
518
+ | listStyle | string | - | Inline style of inner list element. |
519
+ | scrollHeight | string | 14rem | Height of the viewport, a scrollbar is defined if height of list exceeds this value. |
520
+ | invalid | boolean | false | When present, it specifies that the component should have invalid state style. |
521
+ | disabled | boolean | false | When specified, disables the component. |
522
+ | fluid | boolean | null | Spans 100% width of the container when enabled. |
523
+ | dataKey | string | - | A property to uniquely identify an option. |
524
+ | multiple | boolean | false | When specified, allows selecting multiple values. |
525
+ | metaKeySelection | boolean | false | Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. |
526
+ | filter | boolean | false | When specified, displays a filter input at header. |
527
+ | filterPlaceholder | string | - | Placeholder text to show when filter input is empty. |
528
+ | filterLocale | string | - | Locale to use in filtering. The default locale is the host environment's current locale. |
529
+ | filterMatchMode | HintedString<"startsWith" \| "contains" \| "endsWith"> | contains | Defines the filtering algorithm to use when searching the options. |
530
+ | filterFields | string[] | - | Fields used when filtering the options, defaults to optionLabel. |
531
+ | virtualScrollerOptions | any | - | Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it. |
532
+ | autoOptionFocus | boolean | false | Whether to focus on the first visible or selected element. |
533
+ | selectOnFocus | boolean | false | When enabled, the focused option is selected. |
534
+ | focusOnHover | boolean | true | When enabled, the focus is placed on the hovered option. |
535
+ | highlightOnSelect | boolean | true | Whether the selected option will be add highlight class. |
536
+ | checkmark | boolean | false | Whether the selected option will be shown with a check mark. |
537
+ | checkbox | boolean | false | When specified, allows selecting items with checkboxes. |
538
+ | showToggleAll | boolean | true | Whether the header checkbox to toggle all items is shown in multiple mode. |
539
+ | selectAll | boolean | null | Whether all data is selected. When set, it takes precedence over the internal toggle-all state and emits select-all-change instead of mutating the model. |
540
+ | filterMessage | string | '{0} results are available' | Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. |
541
+ | selectionMessage | string | '{0} items selected' | Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. |
542
+ | emptySelectionMessage | string | No selected item | Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. |
543
+ | emptyFilterMessage | string | No results found | Text to display when filtering does not return any results. Defaults to value from PrimeVue locale configuration. |
544
+ | emptyMessage | string | No available options | Text to display when there are no options available. Defaults to value from PrimeVue locale configuration. |
545
+ | striped | boolean | false | Whether to displays rows with alternating colors. |
546
+ | tabindex | string \| number | - | Index of the element in tabbing order. |
547
+ | filterIcon | string | - | Icon to display in filter input. |
548
+ | ariaLabel | string | - | Defines a string value that labels an interactive element. |
549
+ | ariaLabelledby | string | - | Identifier of the underlying input element. |
550
+ | formControl | Record<string, any> | - | Form control object, typically used for handling validation and form state. |
551
+ | dt | any | - | It generates scoped CSS variables using design tokens for the component. |
552
+ | pt | PassThrough<ListboxPassThroughOptions<any>> | - | Used to pass attributes to DOM elements inside the component. |
553
+ | ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
554
+ | unstyled | boolean | false | When enabled, it removes component related styles in the core. |
555
+
556
+ ### Pass Through Options
557
+
558
+ | Name |Type |Description |
559
+ | --- | --- | --- |
560
+ | root | ListboxPassThroughOptionType<T> | Used to pass attributes to the root's DOM element. |
561
+ | header | ListboxPassThroughOptionType<T> | Used to pass attributes to the header's DOM element. |
562
+ | pcHeaderCheckbox | ListboxPassThroughOptionType<T> | Used to pass attributes to the header checkbox's Checkbox component. |
563
+ | pcFilterContainer | any | Used to pass attributes to the IconField component. |
564
+ | pcFilter | any | Used to pass attributes to the InputText component. |
565
+ | pcFilterIconContainer | any | Used to pass attributes to the InputIcon component. |
566
+ | filterIcon | ListboxPassThroughOptionType<T> | Used to pass attributes to the filter icon's DOM element. |
567
+ | listContainer | ListboxPassThroughOptionType<T> | Used to pass attributes to the list container's DOM element. |
568
+ | virtualScroller | any | Used to pass attributes to the VirtualScroller component. |
569
+ | list | ListboxPassThroughOptionType<T> | Used to pass attributes to the list's DOM element. |
570
+ | optionGroup | ListboxPassThroughOptionType<T> | Used to pass attributes to the option group's DOM element. |
571
+ | option | ListboxPassThroughOptionType<T> | Used to pass attributes to the option's DOM element. |
572
+ | pcOptionCheckbox | ListboxPassThroughOptionType<T> | Used to pass attributes to the option checkbox's Checkbox component. |
573
+ | optionCheckIcon | ListboxPassThroughOptionType<T> | Used to pass attributes to the option check icon's DOM element. |
574
+ | optionBlankIcon | ListboxPassThroughOptionType<T> | Used to pass attributes to the option blank icon's DOM element. |
575
+ | emptyMessage | ListboxPassThroughOptionType<T> | Used to pass attributes to the emptyMessage's DOM element. |
576
+ | hiddenFirstFocusableEl | ListboxPassThroughOptionType<T> | Used to pass attributes to the hidden first focusable element's DOM element. |
577
+ | hiddenFilterResult | ListboxPassThroughOptionType<T> | Used to pass attributes to the hidden filter result's DOM element. |
578
+ | hiddenSelectedMessage | ListboxPassThroughOptionType<T> | Used to pass attributes to the hidden selected message's DOM element. |
579
+ | hiddenLastFocusableEl | ListboxPassThroughOptionType<T> | Used to pass attributes to the hidden last focusable element's DOM element. |
580
+ | hooks | any | Used to manage all lifecycle hooks. |
581
+
582
+ ### Theming
583
+
584
+ ### CSS Classes
585
+
586
+ | Class |Description |
587
+ | --- | --- |
588
+ | p-listbox | Class name of the root element |
589
+ | p-listbox-header | Class name of the header element |
590
+ | p-listbox-filter | Class name of the filter element |
591
+ | p-listbox-list-container | Class name of the list container element |
592
+ | p-listbox-list | Class name of the list element |
593
+ | p-listbox-option-group | Class name of the option group element |
594
+ | p-listbox-option | Class name of the option element |
595
+ | p-listbox-option-check-icon | Class name of the option check icon element |
596
+ | p-listbox-option-blank-icon | Class name of the option blank icon element |
597
+ | p-listbox-empty-message | Class name of the empty message element |
598
+
599
+ ### Design Tokens
600
+
601
+ | Token |CSS Variable |Description |
602
+ | --- | --- | --- |
603
+ | listbox.background | --p-listbox-background | Background of root |
604
+ | listbox.disabled.background | --p-listbox-disabled-background | Disabled background of root |
605
+ | listbox.border.color | --p-listbox-border-color | Border color of root |
606
+ | listbox.invalid.border.color | --p-listbox-invalid-border-color | Invalid border color of root |
607
+ | listbox.color | --p-listbox-color | Color of root |
608
+ | listbox.disabled.color | --p-listbox-disabled-color | Disabled color of root |
609
+ | listbox.shadow | --p-listbox-shadow | Shadow of root |
610
+ | listbox.border.radius | --p-listbox-border-radius | Border radius of root |
611
+ | listbox.transition.duration | --p-listbox-transition-duration | Transition duration of root |
612
+ | listbox.list.padding | --p-listbox-list-padding | Padding of list |
613
+ | listbox.list.gap | --p-listbox-list-gap | Gap of list |
614
+ | listbox.list.header.padding | --p-listbox-list-header-padding | Header padding of list |
615
+ | listbox.option.focus.background | --p-listbox-option-focus-background | Focus background of option |
616
+ | listbox.option.selected.background | --p-listbox-option-selected-background | Selected background of option |
617
+ | listbox.option.selected.focus.background | --p-listbox-option-selected-focus-background | Selected focus background of option |
618
+ | listbox.option.color | --p-listbox-option-color | Color of option |
619
+ | listbox.option.focus.color | --p-listbox-option-focus-color | Focus color of option |
620
+ | listbox.option.selected.color | --p-listbox-option-selected-color | Selected color of option |
621
+ | listbox.option.selected.focus.color | --p-listbox-option-selected-focus-color | Selected focus color of option |
622
+ | listbox.option.selected.font.weight | --p-listbox-option-selected-font-weight | Font weight of a selected option |
623
+ | listbox.option.padding | --p-listbox-option-padding | Padding of option |
624
+ | listbox.option.border.radius | --p-listbox-option-border-radius | Border radius of option |
625
+ | listbox.option.striped.background | --p-listbox-option-striped-background | Striped background of option |
626
+ | listbox.option.font.weight | --p-listbox-option-font-weight | Font weight of option |
627
+ | listbox.option.font.size | --p-listbox-option-font-size | Font size of option |
628
+ | listbox.option.group.background | --p-listbox-option-group-background | Background of option group |
629
+ | listbox.option.group.color | --p-listbox-option-group-color | Color of option group |
630
+ | listbox.option.group.font.weight | --p-listbox-option-group-font-weight | Font weight of option group |
631
+ | listbox.option.group.font.size | --p-listbox-option-group-font-size | Font size of option group |
632
+ | listbox.option.group.padding | --p-listbox-option-group-padding | Padding of option group |
633
+ | listbox.checkmark.color | --p-listbox-checkmark-color | Color of checkmark |
634
+ | listbox.checkmark.gutter.start | --p-listbox-checkmark-gutter-start | Gutter start of checkmark |
635
+ | listbox.checkmark.gutter.end | --p-listbox-checkmark-gutter-end | Gutter end of checkmark |
636
+ | listbox.empty.message.padding | --p-listbox-empty-message-padding | Padding of empty message |