@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,276 @@
1
+ # ToggleButton
2
+
3
+ ToggleButton is used to select a boolean value using a button.
4
+
5
+ ## Basic
6
+
7
+ Two-way binding to a boolean property is defined using the standard v-model directive.
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="flex justify-center">
12
+ <ToggleButton v-model="checked" onLabel="On" offLabel="Off" class="w-24" />
13
+ </div>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref } from 'vue';
18
+
19
+ const checked = ref(false);
20
+ <\/script>
21
+ ```
22
+
23
+ ## Customized
24
+
25
+ Use the icon template to customize what the component displays based on its internal state.
26
+
27
+ ```vue
28
+ <template>
29
+ <div class="flex flex-wrap items-center justify-center gap-4">
30
+ <ToggleButton v-model="value1" onLabel="On" offLabel="Off" class="min-w-16" />
31
+ <ToggleButton v-model="value2" onLabel="Locked" offLabel="Unlocked" class="min-w-29">
32
+ <template #icon="{ value }">
33
+ <Lock v-if="value" />
34
+ <LockOpen v-else />
35
+ </template>
36
+ </ToggleButton>
37
+ <ToggleButton v-model="value3" onLabel="Mute" offLabel="Unmute" class="min-w-26">
38
+ <template #icon="{ value }">
39
+ <VolumeUp v-if="value" />
40
+ <VolumeOff v-else />
41
+ </template>
42
+ </ToggleButton>
43
+ </div>
44
+ </template>
45
+
46
+ <script setup>
47
+ import { ref } from 'vue';
48
+ import Lock from '@primeicons/vue/lock';
49
+ import LockOpen from '@primeicons/vue/lock-open';
50
+ import VolumeOff from '@primeicons/vue/volume-off';
51
+ import VolumeUp from '@primeicons/vue/volume-up';
52
+
53
+ const value1 = ref(false);
54
+ const value2 = ref(false);
55
+ const value3 = ref(false);
56
+ <\/script>
57
+ ```
58
+
59
+ ## Sizes
60
+
61
+ ToggleButton provides small and large sizes as alternatives to the base.
62
+
63
+ ```vue
64
+ <template>
65
+ <div class="flex flex-col items-center gap-2">
66
+ <ToggleButton v-model="value1" onLabel="Small" offLabel="Small" size="small" class="min-w-16" />
67
+ <ToggleButton v-model="value2" onLabel="Normal" offLabel="Normal" class="min-w-20" />
68
+ <ToggleButton v-model="value3" onLabel="Large" offLabel="Large" size="large" class="min-w-28" />
69
+ </div>
70
+ </template>
71
+
72
+ <script setup>
73
+ import { ref } from 'vue';
74
+
75
+ const value1 = ref(false);
76
+ const value2 = ref(false);
77
+ const value3 = ref(false);
78
+ <\/script>
79
+ ```
80
+
81
+ ## Invalid
82
+
83
+ The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with form validation.
84
+
85
+ ```vue
86
+ <template>
87
+ <div class="flex items-center justify-center">
88
+ <ToggleButton v-model="checked" :invalid="!checked" onLabel="Invalid" offLabel="Invalid" />
89
+ </div>
90
+ </template>
91
+
92
+ <script setup>
93
+ import { ref } from 'vue';
94
+
95
+ const checked = ref(false);
96
+ <\/script>
97
+ ```
98
+
99
+ ## Disabled
100
+
101
+ When disabled is present, the element cannot be edited and focused.
102
+
103
+ ```vue
104
+ <template>
105
+ <div class="flex items-center justify-center">
106
+ <ToggleButton v-model="checked" disabled onLabel="Disabled" offLabel="Disabled" />
107
+ </div>
108
+ </template>
109
+
110
+ <script setup>
111
+ import { ref } from 'vue';
112
+
113
+ const checked = ref(false);
114
+ <\/script>
115
+ ```
116
+
117
+ ## Fluid
118
+
119
+ The fluid prop makes the component take up the full width of its container when set to true.
120
+
121
+ ```vue
122
+ <template>
123
+ <div class="flex justify-center">
124
+ <ToggleButton v-model="checked" onLabel="On" offLabel="Off" fluid />
125
+ </div>
126
+ </template>
127
+
128
+ <script setup>
129
+ import { ref } from 'vue';
130
+
131
+ const checked = ref(false);
132
+ <\/script>
133
+ ```
134
+
135
+ ## Forms
136
+
137
+ ToggleButton integrates seamlessly with the PrimeVue Forms library.
138
+
139
+ ```vue
140
+ <template>
141
+ <div class="flex justify-center">
142
+ <Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4">
143
+ <div class="flex flex-col items-center gap-1">
144
+ <ToggleButton name="consent" onLabel="Accept All" offLabel="Reject All" class="min-w-40" />
145
+ <Message v-if="$form.consent?.invalid" severity="error" size="small" variant="simple">{{ $form.consent.error?.message }}</Message>
146
+ </div>
147
+ <Button type="submit" severity="secondary">Submit</Button>
148
+ </Form>
149
+ </div>
150
+ </template>
151
+
152
+ <script setup>
153
+ import { ref } from 'vue';
154
+ import { zodResolver } from '@primevue/forms/resolvers/zod';
155
+ import { useToast } from "primevue/usetoast";
156
+ import { z } from 'zod';
157
+
158
+ const toast = useToast();
159
+ const initialValues = ref({
160
+ consent: false
161
+ });
162
+
163
+ const resolver = ref(zodResolver(
164
+ z.object({
165
+ consent: z.boolean().refine((val) => val === true, { message: 'Consent is mandatory.' })
166
+ })
167
+ ));
168
+
169
+ const onFormSubmit = ({ valid }) => {
170
+ if (valid) {
171
+ toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 });
172
+ }
173
+ };
174
+ <\/script>
175
+ ```
176
+
177
+ ## Accessibility
178
+
179
+ Screen Reader ToggleButton component uses an element with button role and updates aria-pressed state for screen readers. Value to describe the component can be defined with aria-labelledby or aria-label props, it is highly suggested to use either of these props as the component changes the label displayed which will result in screen readers to read different labels when the component receives focus. To prevent this, always provide an aria label that does not change related to state. Keyboard Support Key Function tab Moves focus to the button. space Toggles the checked state.
180
+
181
+ ```vue
182
+ <template>
183
+ <span id="rememberme">Remember Me</span>
184
+ <ToggleButton aria-labelledby="rememberme" />
185
+
186
+ <ToggleButton aria-label="Remember Me" />
187
+ </template>
188
+ ```
189
+
190
+ ## Toggle Button API
191
+
192
+ ### Props
193
+
194
+ | Name |Type |Default |Description |
195
+ | --- | --- | --- | --- |
196
+ | modelValue | boolean | false | Value of the component. |
197
+ | defaultValue | boolean | - | The default value for the input when not controlled by `modelValue` . |
198
+ | name | string | - | The name attribute for the element, typically used in form submissions. |
199
+ | onIcon | string | - | Icon for the on state. |
200
+ | offIcon | string | - | Icon for the off state. |
201
+ | onLabel | string | yes | Label for the on state. |
202
+ | offLabel | string | no | Label for the off state. |
203
+ | invalid | boolean | false | When present, it specifies that the component should have invalid state style. |
204
+ | disabled | boolean | false | When present, it specifies that the element should be disabled. |
205
+ | fluid | boolean | null | Spans 100% width of the container when enabled. |
206
+ | readonly | boolean | - | When present, it specifies that an input field is read-only. |
207
+ | tabindex | string | - | Index of the element in tabbing order. |
208
+ | ariaLabelledby | string | - | Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
209
+ | size | HintedString<"small" \| "large"> | - | Defines the size of the component. |
210
+ | formControl | Record<string, any> | - | Form control object, typically used for handling validation and form state. |
211
+ | dt | any | - | It generates scoped CSS variables using design tokens for the component. |
212
+ | pt | PassThrough<ToggleButtonPassThroughOptions<any>> | - | Used to pass attributes to DOM elements inside the component. |
213
+ | ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
214
+ | unstyled | boolean | false | When enabled, it removes component related styles in the core. |
215
+
216
+ ### Pass Through Options
217
+
218
+ | Name |Type |Description |
219
+ | --- | --- | --- |
220
+ | root | ToggleButtonPassThroughOptionType<T> | Used to pass attributes to the root's DOM element. |
221
+ | content | ToggleButtonPassThroughOptionType<T> | Used to pass attributes to the content's DOM element. |
222
+ | icon | ToggleButtonPassThroughOptionType<T> | Used to pass attributes to the icon's DOM element. |
223
+ | label | ToggleButtonPassThroughOptionType<T> | Used to pass attributes to the label's DOM element. |
224
+ | hooks | any | Used to manage all lifecycle hooks. |
225
+
226
+ ### Theming
227
+
228
+ ### CSS Classes
229
+
230
+ | Class |Description |
231
+ | --- | --- |
232
+ | p-togglebutton | Class name of the root element |
233
+ | p-togglebutton-icon | Class name of the icon element |
234
+ | p-togglebutton-label | Class name of the label element |
235
+
236
+ ### Design Tokens
237
+
238
+ | Token |CSS Variable |Description |
239
+ | --- | --- | --- |
240
+ | togglebutton.padding | --p-togglebutton-padding | Padding of root |
241
+ | togglebutton.border.radius | --p-togglebutton-border-radius | Border radius of root |
242
+ | togglebutton.gap | --p-togglebutton-gap | Gap of root |
243
+ | togglebutton.font.size | --p-togglebutton-font-size | Font size of root |
244
+ | togglebutton.font.weight | --p-togglebutton-font-weight | Font weight of root |
245
+ | togglebutton.disabled.background | --p-togglebutton-disabled-background | Disabled background of root |
246
+ | togglebutton.disabled.border.color | --p-togglebutton-disabled-border-color | Disabled border color of root |
247
+ | togglebutton.disabled.color | --p-togglebutton-disabled-color | Disabled color of root |
248
+ | togglebutton.invalid.border.color | --p-togglebutton-invalid-border-color | Invalid border color of root |
249
+ | togglebutton.focus.ring.width | --p-togglebutton-focus-ring-width | Focus ring width of root |
250
+ | togglebutton.focus.ring.style | --p-togglebutton-focus-ring-style | Focus ring style of root |
251
+ | togglebutton.focus.ring.color | --p-togglebutton-focus-ring-color | Focus ring color of root |
252
+ | togglebutton.focus.ring.offset | --p-togglebutton-focus-ring-offset | Focus ring offset of root |
253
+ | togglebutton.focus.ring.shadow | --p-togglebutton-focus-ring-shadow | Focus ring shadow of root |
254
+ | togglebutton.transition.duration | --p-togglebutton-transition-duration | Transition duration of root |
255
+ | togglebutton.sm.font.size | --p-togglebutton-sm-font-size | Sm font size of root |
256
+ | togglebutton.sm.padding | --p-togglebutton-sm-padding | Sm padding of root |
257
+ | togglebutton.lg.font.size | --p-togglebutton-lg-font-size | Lg font size of root |
258
+ | togglebutton.lg.padding | --p-togglebutton-lg-padding | Lg padding of root |
259
+ | togglebutton.background | --p-togglebutton-background | Background of root |
260
+ | togglebutton.checked.background | --p-togglebutton-checked-background | Checked background of root |
261
+ | togglebutton.hover.background | --p-togglebutton-hover-background | Hover background of root |
262
+ | togglebutton.border.color | --p-togglebutton-border-color | Border color of root |
263
+ | togglebutton.color | --p-togglebutton-color | Color of root |
264
+ | togglebutton.hover.color | --p-togglebutton-hover-color | Hover color of root |
265
+ | togglebutton.checked.color | --p-togglebutton-checked-color | Checked color of root |
266
+ | togglebutton.checked.border.color | --p-togglebutton-checked-border-color | Checked border color of root |
267
+ | togglebutton.icon.disabled.color | --p-togglebutton-icon-disabled-color | Disabled color of icon |
268
+ | togglebutton.icon.color | --p-togglebutton-icon-color | Color of icon |
269
+ | togglebutton.icon.hover.color | --p-togglebutton-icon-hover-color | Hover color of icon |
270
+ | togglebutton.icon.checked.color | --p-togglebutton-icon-checked-color | Checked color of icon |
271
+ | togglebutton.content.padding | --p-togglebutton-content-padding | Padding of content |
272
+ | togglebutton.content.border.radius | --p-togglebutton-content-border-radius | Border radius of content |
273
+ | togglebutton.content.checked.shadow | --p-togglebutton-content-checked-shadow | Checked shadow of content |
274
+ | togglebutton.content.sm.padding | --p-togglebutton-content-sm-padding | Sm padding of content |
275
+ | togglebutton.content.lg.padding | --p-togglebutton-content-lg-padding | Lg padding of content |
276
+ | togglebutton.content.checked.background | --p-togglebutton-content-checked-background | Checked background of content |
@@ -0,0 +1,271 @@
1
+ # ToggleSwitch
2
+
3
+ ToggleSwitch is used to select a boolean value.
4
+
5
+ ## Basic
6
+
7
+ Toggles a boolean setting between enabled and disabled states.
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="flex justify-center items-center gap-2">
12
+ <label for="switch">Off</label>
13
+ <ToggleSwitch v-model="checked" inputId="switch" />
14
+ <label for="switch">On</label>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { ref } from 'vue';
20
+
21
+ const checked = ref(false);
22
+ <\/script>
23
+ ```
24
+
25
+ ## Controlled
26
+
27
+ A controlled ToggleSwitch manages the checked state with v-model for two-way value binding.
28
+
29
+ ```vue
30
+ <template>
31
+ <div class="flex justify-center items-center gap-2">
32
+ <ToggleSwitch v-model="checked" inputId="mode" />
33
+ <label for="mode">Airplane Mode</label>
34
+ </div>
35
+ </template>
36
+
37
+ <script setup>
38
+ import { ref } from 'vue';
39
+
40
+ const checked = ref(true);
41
+ <\/script>
42
+ ```
43
+
44
+ ## Template
45
+
46
+ The handle slot is available to display custom content.
47
+
48
+ ```vue
49
+ <template>
50
+ <div class="flex justify-center">
51
+ <ToggleSwitch v-model="checked">
52
+ <template #handle="{ checked }">
53
+ <Check v-if="checked" class="text-xs!" />
54
+ <Times v-else class="text-xs!" />
55
+ </template>
56
+ </ToggleSwitch>
57
+ </div>
58
+ </template>
59
+
60
+ <script setup>
61
+ import { ref } from 'vue';
62
+ import Check from '@primeicons/vue/check';
63
+ import Times from '@primeicons/vue/times';
64
+
65
+ const checked = ref(false);
66
+ <\/script>
67
+ ```
68
+
69
+ ## Customization
70
+
71
+ ToggleSwitch supports customization through the pt property. The appearance, including colors and other visual properties, can be modified by applying custom classes.
72
+
73
+ ```vue
74
+ <template>
75
+ <div>
76
+ <label for="custom" class="max-w-xs mx-auto flex items-start gap-2 bg-slate-50 hover:bg-slate-100 dark:bg-slate-800 hover:dark:bg-slate-700 p-4 rounded-md transition-colors">
77
+ <div class="flex flex-col gap-1 flex-1">
78
+ <span class="m-0 text-medium text-slate-900 dark:text-slate-50">Try Beta Features</span>
79
+ <span class="m-0 text-sm text-slate-400">Experience upcoming features before they're officially released.</span>
80
+ </div>
81
+ <ToggleSwitch
82
+ v-model="checked"
83
+ inputId="custom"
84
+ :pt="{
85
+ slider: { class: checked ? 'bg-blue-300! rounded-md!' : 'bg-slate-300! dark:bg-slate-600! rounded-md!' },
86
+ handle: { class: checked ? 'bg-blue-900!' : 'bg-slate-500!' }
87
+ }"
88
+ />
89
+ </label>
90
+ </div>
91
+ </template>
92
+
93
+ <script setup>
94
+ import { ref } from 'vue';
95
+
96
+ const checked = ref(true);
97
+ <\/script>
98
+ ```
99
+
100
+ ## Disabled
101
+
102
+ When disabled is present, the element cannot be edited and focused.
103
+
104
+ ```vue
105
+ <template>
106
+ <div class="flex justify-center">
107
+ <ToggleSwitch v-model="checked" disabled />
108
+ </div>
109
+ </template>
110
+
111
+ <script setup>
112
+ import { ref } from 'vue';
113
+
114
+ const checked = ref(false);
115
+ <\/script>
116
+ ```
117
+
118
+ ## Invalid
119
+
120
+ The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with form validation.
121
+
122
+ ```vue
123
+ <template>
124
+ <div class="flex justify-center">
125
+ <ToggleSwitch v-model="checked" :invalid="!checked" />
126
+ </div>
127
+ </template>
128
+
129
+ <script setup>
130
+ import { ref } from 'vue';
131
+
132
+ const checked = ref(false);
133
+ <\/script>
134
+ ```
135
+
136
+ ## Forms
137
+
138
+ ToggleSwitch integrates seamlessly with the PrimeVue Forms library.
139
+
140
+ ```vue
141
+ <template>
142
+ <div class="flex justify-center">
143
+ <Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-48">
144
+ <div class="flex flex-col items-center gap-2">
145
+ <ToggleSwitch name="activation" />
146
+ <Message v-if="$form.activation?.invalid" severity="error" size="small" variant="simple">{{ $form.activation.error?.message }}</Message>
147
+ </div>
148
+ <Button type="submit" severity="secondary">Submit</Button>
149
+ </Form>
150
+ </div>
151
+ </template>
152
+
153
+ <script setup>
154
+ import { ref } from 'vue';
155
+ import { zodResolver } from '@primevue/forms/resolvers/zod';
156
+ import { useToast } from "primevue/usetoast";
157
+ import { z } from 'zod';
158
+
159
+ const toast = useToast();
160
+ const initialValues = ref({
161
+ activation: false
162
+ });
163
+ const resolver = ref(zodResolver(
164
+ z.object({
165
+ activation: z.boolean().refine((val) => val === true, { message: 'Activation is required.' })
166
+ })
167
+ ));
168
+ <\/script>
169
+ ```
170
+
171
+ ## Accessibility
172
+
173
+ Screen Reader ToggleSwitch component uses a hidden native checkbox element with switch role internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby , aria-label props. Keyboard Support Key Function tab Moves focus to the switch. space Toggles the checked state.
174
+
175
+ ```vue
176
+ <template>
177
+ <label for="switch1">Remember Me</label>
178
+ <ToggleSwitch inputId="switch1" />
179
+
180
+ <span id="switch2">Remember Me</span>
181
+ <ToggleSwitch aria-labelledby="switch2" />
182
+
183
+ <ToggleSwitch aria-label="Remember Me" />
184
+ </template>
185
+ ```
186
+
187
+ ## Toggle Switch API
188
+
189
+ ### Props
190
+
191
+ | Name |Type |Default |Description |
192
+ | --- | --- | --- | --- |
193
+ | modelValue | string \| boolean | false | Specifies whether a toggleswitch should be checked or not. |
194
+ | defaultValue | string \| boolean | - | The default value for the input when not controlled by `modelValue` . |
195
+ | name | string | - | The name attribute for the element, typically used in form submissions. |
196
+ | trueValue | any | true | Value in checked state. |
197
+ | falseValue | any | false | Value in unchecked state. |
198
+ | invalid | boolean | false | When present, it specifies that the component should have invalid state style. |
199
+ | disabled | boolean | false | When present, it specifies that the component should be disabled. |
200
+ | readonly | boolean | - | When present, it specifies that an input field is read-only. |
201
+ | tabindex | number | - | Index of the element in tabbing order. |
202
+ | inputId | string | - | Identifier of the underlying input element. |
203
+ | inputClass | string \| object | - | Style class of the input field. |
204
+ | inputStyle | object | - | Inline style of the input field. |
205
+ | ariaLabelledby | string | - | Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
206
+ | ariaLabel | string | - | Establishes a string value that labels the component. |
207
+ | formControl | Record<string, any> | - | Form control object, typically used for handling validation and form state. |
208
+ | dt | any | - | It generates scoped CSS variables using design tokens for the component. |
209
+ | pt | PassThrough<ToggleSwitchPassThroughOptions> | - | Used to pass attributes to DOM elements inside the component. |
210
+ | ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
211
+ | unstyled | boolean | false | When enabled, it removes component related styles in the core. |
212
+
213
+ ### Pass Through Options
214
+
215
+ | Name |Type |Description |
216
+ | --- | --- | --- |
217
+ | root | ToggleSwitchPassThroughOptionType | Used to pass attributes to the root's DOM element. |
218
+ | input | ToggleSwitchPassThroughOptionType | Used to pass attributes to the input's DOM element. |
219
+ | slider | ToggleSwitchPassThroughOptionType | Used to pass attributes to the slider's DOM element. |
220
+ | handle | ToggleSwitchPassThroughOptionType | Used to pass attributes to the handle's DOM element. |
221
+ | hooks | any | Used to manage all lifecycle hooks. |
222
+
223
+ ### Theming
224
+
225
+ ### CSS Classes
226
+
227
+ | Class |Description |
228
+ | --- | --- |
229
+ | p-toggleswitch | Class name of the root element |
230
+ | p-toggleswitch-input | Class name of the input element |
231
+ | p-toggleswitch-slider | Class name of the slider element |
232
+ | p-toggleswitch-handle | Class name of the handle element |
233
+
234
+ ### Design Tokens
235
+
236
+ | Token |CSS Variable |Description |
237
+ | --- | --- | --- |
238
+ | toggleswitch.width | --p-toggleswitch-width | Width of root |
239
+ | toggleswitch.height | --p-toggleswitch-height | Height of root |
240
+ | toggleswitch.border.radius | --p-toggleswitch-border-radius | Border radius of root |
241
+ | toggleswitch.gap | --p-toggleswitch-gap | Gap of root |
242
+ | toggleswitch.shadow | --p-toggleswitch-shadow | Shadow of root |
243
+ | toggleswitch.focus.ring.width | --p-toggleswitch-focus-ring-width | Focus ring width of root |
244
+ | toggleswitch.focus.ring.style | --p-toggleswitch-focus-ring-style | Focus ring style of root |
245
+ | toggleswitch.focus.ring.color | --p-toggleswitch-focus-ring-color | Focus ring color of root |
246
+ | toggleswitch.focus.ring.offset | --p-toggleswitch-focus-ring-offset | Focus ring offset of root |
247
+ | toggleswitch.focus.ring.shadow | --p-toggleswitch-focus-ring-shadow | Focus ring shadow of root |
248
+ | toggleswitch.border.width | --p-toggleswitch-border-width | Border width of root |
249
+ | toggleswitch.border.color | --p-toggleswitch-border-color | Border color of root |
250
+ | toggleswitch.hover.border.color | --p-toggleswitch-hover-border-color | Hover border color of root |
251
+ | toggleswitch.checked.border.color | --p-toggleswitch-checked-border-color | Checked border color of root |
252
+ | toggleswitch.checked.hover.border.color | --p-toggleswitch-checked-hover-border-color | Checked hover border color of root |
253
+ | toggleswitch.invalid.border.color | --p-toggleswitch-invalid-border-color | Invalid border color of root |
254
+ | toggleswitch.transition.duration | --p-toggleswitch-transition-duration | Transition duration of root |
255
+ | toggleswitch.slide.duration | --p-toggleswitch-slide-duration | Slide duration of root |
256
+ | toggleswitch.background | --p-toggleswitch-background | Background of root |
257
+ | toggleswitch.disabled.background | --p-toggleswitch-disabled-background | Disabled background of root |
258
+ | toggleswitch.hover.background | --p-toggleswitch-hover-background | Hover background of root |
259
+ | toggleswitch.checked.background | --p-toggleswitch-checked-background | Checked background of root |
260
+ | toggleswitch.checked.hover.background | --p-toggleswitch-checked-hover-background | Checked hover background of root |
261
+ | toggleswitch.handle.border.radius | --p-toggleswitch-handle-border-radius | Border radius of handle |
262
+ | toggleswitch.handle.size | --p-toggleswitch-handle-size | Size of handle |
263
+ | toggleswitch.handle.background | --p-toggleswitch-handle-background | Background of handle |
264
+ | toggleswitch.handle.disabled.background | --p-toggleswitch-handle-disabled-background | Disabled background of handle |
265
+ | toggleswitch.handle.hover.background | --p-toggleswitch-handle-hover-background | Hover background of handle |
266
+ | toggleswitch.handle.checked.background | --p-toggleswitch-handle-checked-background | Checked background of handle |
267
+ | toggleswitch.handle.checked.hover.background | --p-toggleswitch-handle-checked-hover-background | Checked hover background of handle |
268
+ | toggleswitch.handle.color | --p-toggleswitch-handle-color | Color of handle |
269
+ | toggleswitch.handle.hover.color | --p-toggleswitch-handle-hover-color | Hover color of handle |
270
+ | toggleswitch.handle.checked.color | --p-toggleswitch-handle-checked-color | Checked color of handle |
271
+ | toggleswitch.handle.checked.hover.color | --p-toggleswitch-handle-checked-hover-color | Checked hover color of handle |
@@ -0,0 +1,140 @@
1
+ # Toolbar
2
+
3
+ Toolbar is a grouping component for buttons and other content.
4
+
5
+ ## Basic
6
+
7
+ Combines action buttons and controls in a horizontal bar.
8
+
9
+ ```vue
10
+ <template>
11
+ <Toolbar>
12
+ <template #start>
13
+ <Button class="mr-2" variant="text" severity="secondary">
14
+ <Plus />
15
+ </Button>
16
+ <Button class="mr-2" variant="text" severity="secondary">
17
+ <Print />
18
+ </Button>
19
+ <Button variant="text" severity="secondary">
20
+ <Upload />
21
+ </Button>
22
+ </template>
23
+
24
+ <template #center>
25
+ <IconField iconPosition="left">
26
+ <InputIcon>
27
+ <Search />
28
+ </InputIcon>
29
+ <InputText placeholder="Search" />
30
+ </IconField>
31
+ </template>
32
+
33
+ <template #end>
34
+ <Button severity="secondary" variant="outlined" size="small">Cancel</Button>
35
+ <Button size="small" class="ml-2">Save</Button>
36
+ </template>
37
+ </Toolbar>
38
+ </template>
39
+
40
+ <script setup>
41
+ import Plus from '@primeicons/vue/plus';
42
+ import Print from '@primeicons/vue/print';
43
+ import Search from '@primeicons/vue/search';
44
+ import Upload from '@primeicons/vue/upload';
45
+ <\/script>
46
+ ```
47
+
48
+ ## Custom
49
+
50
+ A customized toolbar with navigation bar functionality.
51
+
52
+ ```vue
53
+ <template>
54
+ <Toolbar class="@container" :style="{ 'border-radius': '3rem', padding: '0.75rem 1rem 0.75rem 1.5rem', background: 'var(--p-surface-900)', border: 'none' }">
55
+ <template #start>
56
+ <div class="flex items-center gap-1">
57
+ <span class="text-xl" style="color: var(--p-primary-400)">
58
+ <Prime />
59
+ </span>
60
+ <span class="font-bold text-lg ml-2" style="color: var(--p-surface-0)">Brand</span>
61
+ </div>
62
+ <div class="ml-6 hidden @min-[620px]:flex gap-1">
63
+ <Button variant="text" size="small" class="text-surface-0! hover:bg-surface-700!">Products</Button>
64
+ <Button variant="text" size="small" class="text-surface-0! hover:bg-surface-700!">Solutions</Button>
65
+ <Button variant="text" size="small" class="text-surface-0! hover:bg-surface-700!">Resources</Button>
66
+ <Button variant="text" size="small" class="text-surface-0! hover:bg-surface-700!">Pricing</Button>
67
+ </div>
68
+ </template>
69
+
70
+ <template #end>
71
+ <div class="flex items-center gap-2">
72
+ <Button variant="text" size="small" iconOnly aria-label="Search" class="text-surface-0! hover:bg-surface-700!">
73
+ <Search />
74
+ </Button>
75
+ <Button severity="contrast" size="small">Get Started</Button>
76
+ <Avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
77
+ </div>
78
+ </template>
79
+ </Toolbar>
80
+ </template>
81
+
82
+ <script setup>
83
+ import Prime from '@primeicons/vue/prime';
84
+ import Search from '@primeicons/vue/search';
85
+ <\/script>
86
+ ```
87
+
88
+ ## Accessibility
89
+
90
+ Screen Reader Toolbar uses toolbar role for the root element, aria-orientation is not included as it defaults to horizontal . Any valid attribute is passed to the root element so you may add additional properties like aria-labelledby and aria-labelled to define the element if required. Keyboard Support Component does not include any interactive elements. Arbitrary content can be placed with templating and elements like buttons inside should follow the page tab sequence.
91
+
92
+ ```vue
93
+ <Toolbar aria-label="Actions">
94
+ Content
95
+ </Toolbar>
96
+ ```
97
+
98
+ ## Toolbar API
99
+
100
+ ### Props
101
+
102
+ | Name |Type |Default |Description |
103
+ | --- | --- | --- | --- |
104
+ | ariaLabelledby | string | - | Defines a string value that labels an interactive element. |
105
+ | dt | any | - | It generates scoped CSS variables using design tokens for the component. |
106
+ | pt | PassThrough<ToolbarPassThroughOptions> | - | Used to pass attributes to DOM elements inside the component. |
107
+ | ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
108
+ | unstyled | boolean | false | When enabled, it removes component related styles in the core. |
109
+
110
+ ### Pass Through Options
111
+
112
+ | Name |Type |Description |
113
+ | --- | --- | --- |
114
+ | root | ToolbarPassThroughOptionType | Used to pass attributes to the root's DOM element. |
115
+ | start | ToolbarPassThroughOptionType | Used to pass attributes to the start's DOM element. |
116
+ | center | ToolbarPassThroughOptionType | Used to pass attributes to the center's DOM element. |
117
+ | end | ToolbarPassThroughOptionType | Used to pass attributes to the right's DOM element. |
118
+ | hooks | any | Used to manage all lifecycle hooks. |
119
+
120
+ ### Theming
121
+
122
+ ### CSS Classes
123
+
124
+ | Class |Description |
125
+ | --- | --- |
126
+ | p-toolbar | Class name of the root element |
127
+ | p-toolbar-start | Class name of the start element |
128
+ | p-toolbar-center | Class name of the center element |
129
+ | p-toolbar-end | Class name of the end element |
130
+
131
+ ### Design Tokens
132
+
133
+ | Token |CSS Variable |Description |
134
+ | --- | --- | --- |
135
+ | toolbar.background | --p-toolbar-background | Background of root |
136
+ | toolbar.border.color | --p-toolbar-border-color | Border color of root |
137
+ | toolbar.border.radius | --p-toolbar-border-radius | Border radius of root |
138
+ | toolbar.color | --p-toolbar-color | Color of root |
139
+ | toolbar.gap | --p-toolbar-gap | Gap of root |
140
+ | toolbar.padding | --p-toolbar-padding | Padding of root |