@exhaustive-ui/mcp 0.0.0-stage → 3.0.0-alpha.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 (121) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +167 -2
  3. package/data/components/accordion.md +421 -0
  4. package/data/components/animateonscroll.md +163 -0
  5. package/data/components/autocomplete.md +1077 -0
  6. package/data/components/autofocus.md +38 -0
  7. package/data/components/avatar.md +417 -0
  8. package/data/components/badge.md +234 -0
  9. package/data/components/blockui.md +108 -0
  10. package/data/components/breadcrumb.md +178 -0
  11. package/data/components/button.md +774 -0
  12. package/data/components/card.md +138 -0
  13. package/data/components/carousel.md +440 -0
  14. package/data/components/cascadeselect.md +1387 -0
  15. package/data/components/chart.md +1178 -0
  16. package/data/components/checkbox.md +529 -0
  17. package/data/components/chip.md +180 -0
  18. package/data/components/colorpicker.md +301 -0
  19. package/data/components/confirmdialog.md +287 -0
  20. package/data/components/confirmpopup.md +417 -0
  21. package/data/components/contextmenu.md +491 -0
  22. package/data/components/dataview.md +600 -0
  23. package/data/components/datepicker.md +1262 -0
  24. package/data/components/dialog.md +622 -0
  25. package/data/components/divider.md +250 -0
  26. package/data/components/dock.md +500 -0
  27. package/data/components/dragdrop.md +285 -0
  28. package/data/components/drawer.md +510 -0
  29. package/data/components/dynamicdialog.md +109 -0
  30. package/data/components/editor.md +291 -0
  31. package/data/components/fieldset.md +182 -0
  32. package/data/components/fileupload.md +430 -0
  33. package/data/components/floatlabel.md +155 -0
  34. package/data/components/fluid.md +72 -0
  35. package/data/components/focustrap.md +65 -0
  36. package/data/components/galleria.md +627 -0
  37. package/data/components/iconfield.md +246 -0
  38. package/data/components/iftalabel.md +105 -0
  39. package/data/components/imagecompare.md +97 -0
  40. package/data/components/inplace.md +233 -0
  41. package/data/components/inputgroup.md +306 -0
  42. package/data/components/inputmask.md +518 -0
  43. package/data/components/inputnumber.md +675 -0
  44. package/data/components/inputotp.md +336 -0
  45. package/data/components/inputtext.md +488 -0
  46. package/data/components/keyfilter.md +85 -0
  47. package/data/components/knob.md +462 -0
  48. package/data/components/listbox.md +798 -0
  49. package/data/components/llms.md +28 -0
  50. package/data/components/megamenu.md +587 -0
  51. package/data/components/menu.md +483 -0
  52. package/data/components/menubar.md +462 -0
  53. package/data/components/message.md +449 -0
  54. package/data/components/metergroup.md +241 -0
  55. package/data/components/multiselect.md +1047 -0
  56. package/data/components/orderlist.md +342 -0
  57. package/data/components/organizationchart.md +197 -0
  58. package/data/components/overlay.md +217 -0
  59. package/data/components/paginator.md +314 -0
  60. package/data/components/panel.md +214 -0
  61. package/data/components/panelmenu.md +699 -0
  62. package/data/components/password.md +570 -0
  63. package/data/components/picklist.md +420 -0
  64. package/data/components/popover.md +378 -0
  65. package/data/components/progressbar.md +181 -0
  66. package/data/components/progressspinner.md +91 -0
  67. package/data/components/radiobutton.md +377 -0
  68. package/data/components/rating.md +312 -0
  69. package/data/components/ripple.md +89 -0
  70. package/data/components/scroller.md +122 -0
  71. package/data/components/scrollpanel.md +149 -0
  72. package/data/components/scrolltop.md +105 -0
  73. package/data/components/select.md +1206 -0
  74. package/data/components/selectbutton.md +356 -0
  75. package/data/components/skeleton.md +242 -0
  76. package/data/components/slider.md +337 -0
  77. package/data/components/speeddial.md +589 -0
  78. package/data/components/splitbutton.md +945 -0
  79. package/data/components/splitter.md +196 -0
  80. package/data/components/stepper.md +411 -0
  81. package/data/components/styleclass.md +126 -0
  82. package/data/components/table.md +4557 -0
  83. package/data/components/tabs.md +467 -0
  84. package/data/components/tag.md +200 -0
  85. package/data/components/terminal.md +118 -0
  86. package/data/components/textarea.md +416 -0
  87. package/data/components/tieredmenu.md +578 -0
  88. package/data/components/timeline.md +310 -0
  89. package/data/components/toast.md +596 -0
  90. package/data/components/togglebutton.md +356 -0
  91. package/data/components/toggleswitch.md +285 -0
  92. package/data/components/toolbar.md +182 -0
  93. package/data/components/tooltip.md +211 -0
  94. package/data/components/tree.md +746 -0
  95. package/data/components/treeselect.md +912 -0
  96. package/data/components/treetable.md +2814 -0
  97. package/data/components.json +43751 -0
  98. package/data/llms-full.txt +47433 -0
  99. package/data/llms.txt +121 -0
  100. package/data/manifest.json +46513 -0
  101. package/data/pages/accessibility.md +28 -0
  102. package/data/pages/animations.md +28 -0
  103. package/data/pages/configuration.md +210 -0
  104. package/data/pages/contribution.md +20 -0
  105. package/data/pages/customicons.md +20 -0
  106. package/data/pages/faq.md +20 -0
  107. package/data/pages/icons.md +66 -0
  108. package/data/pages/installation.md +71 -0
  109. package/data/pages/llms.md +61 -0
  110. package/data/pages/passthrough.md +32 -0
  111. package/data/pages/philosophy.md +28 -0
  112. package/data/pages/primeflex.md +20 -0
  113. package/data/pages/rtl.md +12 -0
  114. package/data/pages/styled.md +132 -0
  115. package/data/pages/tailwind.md +40 -0
  116. package/data/pages/unstyled.md +39 -0
  117. package/data/snapshot.json +9 -0
  118. package/dist/index.d.mts +448 -0
  119. package/dist/index.mjs +2501 -0
  120. package/dist/index.mjs.map +1 -0
  121. package/package.json +67 -3
@@ -0,0 +1,356 @@
1
+ # Angular ToggleButton Component
2
+
3
+ ToggleButton is used to select a boolean value using a button.
4
+
5
+ ## Accessibility
6
+
7
+ 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 ariaLabelledBy or ariaLabel 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.
8
+
9
+ ## Basic
10
+
11
+ Two-way binding to a boolean property is defined using the standard ngModel directive.
12
+
13
+ ```typescript
14
+ import { Component } from '@angular/core';
15
+ import { FormsModule } from '@angular/forms';
16
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
17
+
18
+ @Component({
19
+ template: `
20
+ <div class="card flex justify-center">
21
+ <p-togglebutton [(ngModel)]="checked" onLabel="On" offLabel="Off" class="w-24" />
22
+ </div>
23
+ `,
24
+ standalone: true,
25
+ imports: [ToggleButtonModule, FormsModule]
26
+ })
27
+ export class TogglebuttonBasicDemo {
28
+ checked: boolean = false;
29
+ }
30
+ ```
31
+
32
+ ## Customized
33
+
34
+ Icons and Labels can be customized using onLabel , offLabel , onIcon and offIcon properties.
35
+
36
+ ```typescript
37
+ import { Component } from '@angular/core';
38
+ import { FormsModule } from '@angular/forms';
39
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
40
+
41
+ @Component({
42
+ template: `
43
+ <div class="card flex justify-center">
44
+ <p-togglebutton [(ngModel)]="checked" onLabel="Locked" offLabel="Unlocked" onIcon="pi pi-check" offIcon="pi pi-times" onIcon="pi pi-lock" offIcon="pi pi-lock-open" class="w-36" ariaLabel="Do you confirm" />
45
+ </div>
46
+ `,
47
+ standalone: true,
48
+ imports: [ToggleButtonModule, FormsModule]
49
+ })
50
+ export class TogglebuttonCustomizedDemo {
51
+ checked: boolean = false;
52
+ }
53
+ ```
54
+
55
+ ## Disabled
56
+
57
+ When disabled is present, the element cannot be edited and focused.
58
+
59
+ ```typescript
60
+ import { Component } from '@angular/core';
61
+ import { FormsModule } from '@angular/forms';
62
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
63
+
64
+ @Component({
65
+ template: `
66
+ <div class="card flex justify-center">
67
+ <p-togglebutton disabled="true" onIcon="pi pi-check" offIcon="pi pi-times" [(ngModel)]="checked" onLabel="Yes" offLabel="No" class="w-full sm:w-40" ariaLabel="Confirmation" />
68
+ </div>
69
+ `,
70
+ standalone: true,
71
+ imports: [ToggleButtonModule, FormsModule]
72
+ })
73
+ export class TogglebuttonDisabledDemo {
74
+ checked: boolean = false;
75
+ }
76
+ ```
77
+
78
+ ## Fluid
79
+
80
+ The fluid prop makes the component take up the full width of its container when set to true.
81
+
82
+ ```typescript
83
+ import { Component } from '@angular/core';
84
+ import { FormsModule } from '@angular/forms';
85
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
86
+
87
+ @Component({
88
+ template: `
89
+ <div class="card flex justify-center">
90
+ <p-togglebutton [(ngModel)]="checked" onLabel="On" offLabel="Off" fluid />
91
+ </div>
92
+ `,
93
+ standalone: true,
94
+ imports: [ToggleButtonModule, FormsModule]
95
+ })
96
+ export class TogglebuttonFluidDemo {
97
+ checked: boolean = false;
98
+ }
99
+ ```
100
+
101
+ ## Invalid
102
+
103
+ The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms.
104
+
105
+ ```typescript
106
+ import { Component } from '@angular/core';
107
+ import { FormsModule } from '@angular/forms';
108
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
109
+
110
+ @Component({
111
+ template: `
112
+ <div class="card flex justify-center">
113
+ <p-togglebutton [(ngModel)]="checked" onIcon="pi pi-check" offIcon="pi pi-times" [invalid]="!checked" class="w-full sm:w-40" aria-label="Confirmation" />
114
+ </div>
115
+ `,
116
+ standalone: true,
117
+ imports: [ToggleButtonModule, FormsModule]
118
+ })
119
+ export class TogglebuttonInvalidDemo {
120
+ checked: boolean = false;
121
+ }
122
+ ```
123
+
124
+ ## reactiveforms-doc
125
+
126
+ ToggleButton can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
127
+
128
+ ```typescript
129
+ import { Component, inject } from '@angular/core';
130
+ import { ReactiveFormsModule } from '@angular/forms';
131
+ import { MessageModule } from '@exhaustive-ui/core/message';
132
+ import { ToastModule } from '@exhaustive-ui/core/toast';
133
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
134
+ import { ButtonModule } from '@exhaustive-ui/core/button';
135
+ import { MessageService } from '@exhaustive-ui/core/api';
136
+
137
+ @Component({
138
+ template: `
139
+ <p-toast />
140
+ <div class="card flex justify-center">
141
+ <form [formGroup]="exampleForm" (ngSubmit)="onSubmit()" class="flex flex-col items-center gap-4">
142
+ <div class="flex flex-col items-center gap-1">
143
+ <p-togglebutton name="consent" formControlName="checked" [invalid]="isInvalid('checked')" onLabel="Accept All" offLabel="Reject All" class="min-w-40" />
144
+ @if (isInvalid('checked')) {
145
+ <p-message severity="error" size="small" variant="simple">Consent is mandatory.</p-message>
146
+ }
147
+ </div>
148
+ <button pButton type="submit"><span pButtonLabel>Submit</span></button>
149
+ </form>
150
+ </div>
151
+ `,
152
+ standalone: true,
153
+ imports: [MessageModule, ToastModule, ToggleButtonModule, ButtonModule, ReactiveFormsModule]
154
+ })
155
+ export class TogglebuttonReactiveformsDemo {
156
+ messageService = inject(MessageService);
157
+ exampleForm: FormGroup | undefined;
158
+ formSubmitted: boolean = false;
159
+
160
+ constructor() {
161
+ this.exampleForm = this.fb.group({
162
+ checked: [false, Validators.requiredTrue]
163
+ });
164
+ }
165
+
166
+ onSubmit() {
167
+ this.formSubmitted = true;
168
+ if (this.exampleForm.valid) {
169
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
170
+ this.exampleForm.reset();
171
+ this.formSubmitted = false;
172
+ }
173
+ }
174
+
175
+ isInvalid(controlName: string) {
176
+ const control = this.exampleForm.get(controlName);
177
+ return control?.invalid && (control.touched || this.formSubmitted);
178
+ }
179
+ }
180
+ ```
181
+
182
+ ## Sizes
183
+
184
+ ToggleButton provides small and large sizes as alternatives to the base.
185
+
186
+ ```typescript
187
+ import { Component } from '@angular/core';
188
+ import { FormsModule } from '@angular/forms';
189
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
190
+
191
+ @Component({
192
+ template: `
193
+ <div class="card flex flex-col items-center gap-4">
194
+ <p-togglebutton [(ngModel)]="value1" onLabel="On" offLabel="Off" size="small" class="min-w-16" />
195
+ <p-togglebutton [(ngModel)]="value2" onLabel="On" offLabel="Off" class="min-w-20" />
196
+ <p-togglebutton [(ngModel)]="value3" onLabel="On" offLabel="Off" size="large" class="min-w-24" />
197
+ </div>
198
+ `,
199
+ standalone: true,
200
+ imports: [ToggleButtonModule, FormsModule]
201
+ })
202
+ export class TogglebuttonSizesDemo {
203
+ value1: boolean = false;
204
+ value2: boolean = false;
205
+ value3: boolean = false;
206
+ }
207
+ ```
208
+
209
+ ## templatedrivenforms-doc
210
+
211
+ ```typescript
212
+ import { Component, inject } from '@angular/core';
213
+ import { FormsModule } from '@angular/forms';
214
+ import { MessageModule } from '@exhaustive-ui/core/message';
215
+ import { ToastModule } from '@exhaustive-ui/core/toast';
216
+ import { ToggleButtonModule } from '@exhaustive-ui/core/togglebutton';
217
+ import { ButtonModule } from '@exhaustive-ui/core/button';
218
+ import { MessageService } from '@exhaustive-ui/core/api';
219
+
220
+ @Component({
221
+ template: `
222
+ <p-toast />
223
+ <div class="card flex justify-center">
224
+ <form #exampleForm="ngForm" (ngSubmit)="onSubmit(exampleForm)" class="flex flex-col items-center gap-4">
225
+ <div class="flex flex-col items-center gap-1">
226
+ <p-togglebutton #model="ngModel" [(ngModel)]="checked" [invalid]="model.invalid && (model.touched || exampleForm.submitted)" name="country" onLabel="Accept All" offLabel="Reject All" required class="min-w-40" />
227
+ @if (model.invalid && (model.touched || exampleForm.submitted)) {
228
+ <p-message severity="error" size="small" variant="simple">Consent is mandatory.</p-message>
229
+ }
230
+ </div>
231
+ <button pButton type="submit">
232
+ <span pButtonLabel>Submit</span>
233
+ </button>
234
+ </form>
235
+ </div>
236
+ `,
237
+ standalone: true,
238
+ imports: [MessageModule, ToastModule, ToggleButtonModule, ButtonModule, FormsModule]
239
+ })
240
+ export class TogglebuttonTemplatedrivenformsDemo {
241
+ messageService = inject(MessageService);
242
+ checked: boolean;
243
+
244
+ onSubmit(form: any) {
245
+ if (form.valid) {
246
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 });
247
+ form.resetForm();
248
+ }
249
+ }
250
+ }
251
+ ```
252
+
253
+ ## Toggle Button
254
+
255
+ ToggleButton is used to select a boolean value using a button.
256
+
257
+ ### Props
258
+
259
+ | Name | Type | Default | Description |
260
+ |------|------|---------|-------------|
261
+ | dt | InputSignal<Object> | undefined | Defines scoped design tokens of the component. |
262
+ | unstyled | InputSignal<boolean> | undefined | Indicates whether the component should be rendered without styles. |
263
+ | pt | InputSignal<ToggleButtonPassThrough> | undefined | Used to pass attributes to DOM elements inside the component. |
264
+ | ptOptions | InputSignal<PassThroughOptions> | undefined | Used to configure passthrough(pt) options of the component. |
265
+ | required | InputSignalWithTransform<boolean, unknown> | false | There must be a value (if set). |
266
+ | invalid | InputSignalWithTransform<boolean, unknown> | false | When present, it specifies that the component should have invalid state style. |
267
+ | disabled | InputSignalWithTransform<boolean, unknown> | false | When present, it specifies that the component should have disabled state style. |
268
+ | name | InputSignal<string> | undefined | When present, it specifies that the name of the input. |
269
+ | onLabel | InputSignal<string> | ... | Label for the on state. |
270
+ | offLabel | InputSignal<string> | ... | Label for the off state. |
271
+ | onIcon | InputSignal<string> | ... | Icon for the on state. |
272
+ | offIcon | InputSignal<string> | ... | Icon for the off state. |
273
+ | ariaLabel | InputSignal<string> | ... | Defines a string that labels the input for accessibility. |
274
+ | ariaLabelledBy | InputSignal<string> | ... | Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
275
+ | tabindex | InputSignalWithTransform<number, unknown> | ... | Index of the element in tabbing order. |
276
+ | iconPos | InputSignal<"left" \| "right"> | ... | Position of the icon. |
277
+ | autofocus | InputSignalWithTransform<boolean, unknown> | ... | When present, it specifies that the component should automatically get focus on load. |
278
+ | size | InputSignal<"small" \| "large"> | ... | Defines the size of the component. |
279
+ | allowEmpty | InputSignal<boolean> | ... | Whether selection can not be cleared. |
280
+ | fluid | InputSignalWithTransform<boolean, unknown> | undefined | Spans 100% width of the container when enabled. |
281
+
282
+ ### Emits
283
+
284
+ | Name | Parameters | Description |
285
+ |------|------------|-------------|
286
+ | onChange | event: ToggleButtonChangeEvent | Callback to invoke on value change. |
287
+
288
+ ### Templates
289
+
290
+ | Name | Type | Description |
291
+ |------|------|-------------|
292
+ | icon | TemplateRef<ToggleButtonIconTemplateContext> | Custom icon template. |
293
+ | content | TemplateRef<ToggleButtonContentTemplateContext> | Custom content template. |
294
+
295
+ ## Pass Through Options
296
+
297
+ | Name | Type | Description |
298
+ |------|------|-------------|
299
+ | root | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the root's DOM element. |
300
+ | content | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the content's DOM element. |
301
+ | icon | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the icon's DOM element. |
302
+ | label | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the label's DOM element. |
303
+
304
+ ## Theming
305
+
306
+ ### CSS Classes
307
+
308
+ | Class | Description |
309
+ |-------|-------------|
310
+ | p-togglebutton | Class name of the root element |
311
+ | p-togglebutton-icon | Class name of the icon element |
312
+ | p-togglebutton-icon-left | Class name of the left icon |
313
+ | p-togglebutton-icon-right | Class name of the right icon |
314
+ | p-togglebutton-label | Class name of the label element |
315
+
316
+ ### Design Tokens
317
+
318
+ | Token | CSS Variable | Description |
319
+ |-------|--------------|-------------|
320
+ | togglebutton.padding | --p-togglebutton-padding | Padding of root |
321
+ | togglebutton.border.radius | --p-togglebutton-border-radius | Border radius of root |
322
+ | togglebutton.gap | --p-togglebutton-gap | Gap of root |
323
+ | togglebutton.font.weight | --p-togglebutton-font-weight | Font weight of root |
324
+ | togglebutton.disabled.background | --p-togglebutton-disabled-background | Disabled background of root |
325
+ | togglebutton.disabled.border.color | --p-togglebutton-disabled-border-color | Disabled border color of root |
326
+ | togglebutton.disabled.color | --p-togglebutton-disabled-color | Disabled color of root |
327
+ | togglebutton.invalid.border.color | --p-togglebutton-invalid-border-color | Invalid border color of root |
328
+ | togglebutton.focus.ring.width | --p-togglebutton-focus-ring-width | Focus ring width of root |
329
+ | togglebutton.focus.ring.style | --p-togglebutton-focus-ring-style | Focus ring style of root |
330
+ | togglebutton.focus.ring.color | --p-togglebutton-focus-ring-color | Focus ring color of root |
331
+ | togglebutton.focus.ring.offset | --p-togglebutton-focus-ring-offset | Focus ring offset of root |
332
+ | togglebutton.focus.ring.shadow | --p-togglebutton-focus-ring-shadow | Focus ring shadow of root |
333
+ | togglebutton.transition.duration | --p-togglebutton-transition-duration | Transition duration of root |
334
+ | togglebutton.sm.font.size | --p-togglebutton-sm-font-size | Sm font size of root |
335
+ | togglebutton.sm.padding | --p-togglebutton-sm-padding | Sm padding of root |
336
+ | togglebutton.lg.font.size | --p-togglebutton-lg-font-size | Lg font size of root |
337
+ | togglebutton.lg.padding | --p-togglebutton-lg-padding | Lg padding of root |
338
+ | togglebutton.background | --p-togglebutton-background | Background of root |
339
+ | togglebutton.checked.background | --p-togglebutton-checked-background | Checked background of root |
340
+ | togglebutton.hover.background | --p-togglebutton-hover-background | Hover background of root |
341
+ | togglebutton.border.color | --p-togglebutton-border-color | Border color of root |
342
+ | togglebutton.color | --p-togglebutton-color | Color of root |
343
+ | togglebutton.hover.color | --p-togglebutton-hover-color | Hover color of root |
344
+ | togglebutton.checked.color | --p-togglebutton-checked-color | Checked color of root |
345
+ | togglebutton.checked.border.color | --p-togglebutton-checked-border-color | Checked border color of root |
346
+ | togglebutton.icon.disabled.color | --p-togglebutton-icon-disabled-color | Disabled color of icon |
347
+ | togglebutton.icon.color | --p-togglebutton-icon-color | Color of icon |
348
+ | togglebutton.icon.hover.color | --p-togglebutton-icon-hover-color | Hover color of icon |
349
+ | togglebutton.icon.checked.color | --p-togglebutton-icon-checked-color | Checked color of icon |
350
+ | togglebutton.content.padding | --p-togglebutton-content-padding | Padding of content |
351
+ | togglebutton.content.border.radius | --p-togglebutton-content-border-radius | Border radius of content |
352
+ | togglebutton.content.checked.shadow | --p-togglebutton-content-checked-shadow | Checked shadow of content |
353
+ | togglebutton.content.sm.padding | --p-togglebutton-content-sm-padding | Sm padding of content |
354
+ | togglebutton.content.lg.padding | --p-togglebutton-content-lg-padding | Lg padding of content |
355
+ | togglebutton.content.checked.background | --p-togglebutton-content-checked-background | Checked background of content |
356
+
@@ -0,0 +1,285 @@
1
+ # Angular ToggleSwitch Component
2
+
3
+ ToggleSwitch is used to select a boolean value.
4
+
5
+ ## Accessibility
6
+
7
+ Screen Reader InputSwitch 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 ariaLabelledBy , ariaLabel props.
8
+
9
+ ## Basic
10
+
11
+ Two-way value binding is defined using ngModel .
12
+
13
+ ```typescript
14
+ import { Component } from '@angular/core';
15
+ import { FormsModule } from '@angular/forms';
16
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
17
+
18
+ @Component({
19
+ template: `
20
+ <div class="card flex justify-center">
21
+ <p-toggleswitch [(ngModel)]="checked" />
22
+ </div>
23
+ `,
24
+ standalone: true,
25
+ imports: [ToggleSwitchModule, FormsModule]
26
+ })
27
+ export class ToggleswitchBasicDemo {
28
+ checked: boolean = false;
29
+ }
30
+ ```
31
+
32
+ ## Disabled
33
+
34
+ When disabled is present, the element cannot be edited and focused.
35
+
36
+ ```typescript
37
+ import { Component } from '@angular/core';
38
+ import { FormsModule } from '@angular/forms';
39
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
40
+
41
+ @Component({
42
+ template: `
43
+ <div class="card flex justify-center">
44
+ <p-toggleswitch [(ngModel)]="checked" [disabled]="true" />
45
+ </div>
46
+ `,
47
+ standalone: true,
48
+ imports: [ToggleSwitchModule, FormsModule]
49
+ })
50
+ export class ToggleswitchDisabledDemo {
51
+ checked: boolean = false;
52
+ }
53
+ ```
54
+
55
+ ## Invalid
56
+
57
+ The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms.
58
+
59
+ ```typescript
60
+ import { Component } from '@angular/core';
61
+ import { FormsModule } from '@angular/forms';
62
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
63
+
64
+ @Component({
65
+ template: `
66
+ <div class="card flex justify-center">
67
+ <p-toggleswitch [(ngModel)]="checked" [invalid]="!checked" />
68
+ </div>
69
+ `,
70
+ standalone: true,
71
+ imports: [ToggleSwitchModule, FormsModule]
72
+ })
73
+ export class ToggleswitchInvalidDemo {
74
+ checked: boolean = false;
75
+ }
76
+ ```
77
+
78
+ ## Preselection
79
+
80
+ Enabling ngModel property displays the component as active initially.
81
+
82
+ ```typescript
83
+ import { Component } from '@angular/core';
84
+ import { FormsModule } from '@angular/forms';
85
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
86
+
87
+ @Component({
88
+ template: `
89
+ <div class="card flex justify-center">
90
+ <p-toggleswitch [(ngModel)]="checked" />
91
+ </div>
92
+ `,
93
+ standalone: true,
94
+ imports: [ToggleSwitchModule, FormsModule]
95
+ })
96
+ export class ToggleswitchPreselectionDemo {
97
+ checked: boolean = true;
98
+ }
99
+ ```
100
+
101
+ ## reactiveforms-doc
102
+
103
+ ToggleSwitch can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
104
+
105
+ ```typescript
106
+ import { Component, inject } from '@angular/core';
107
+ import { ReactiveFormsModule } from '@angular/forms';
108
+ import { MessageModule } from '@exhaustive-ui/core/message';
109
+ import { ToastModule } from '@exhaustive-ui/core/toast';
110
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
111
+ import { ButtonModule } from '@exhaustive-ui/core/button';
112
+ import { MessageService } from '@exhaustive-ui/core/api';
113
+
114
+ @Component({
115
+ template: `
116
+ <p-toast />
117
+ <div class="card flex justify-center">
118
+ <form [formGroup]="exampleForm" (ngSubmit)="onSubmit()" class="flex flex-col gap-4 w-48">
119
+ <div class="flex flex-col items-center gap-2">
120
+ <p-toggleswitch name="activation" formControlName="activation" [invalid]="isInvalid('activation')" />
121
+ @if (isInvalid('activation')) {
122
+ <p-message severity="error" size="small" variant="simple">Activation is required.</p-message>
123
+ }
124
+ </div>
125
+ <button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
126
+ </form>
127
+ </div>
128
+ `,
129
+ standalone: true,
130
+ imports: [MessageModule, ToastModule, ToggleSwitchModule, ButtonModule, ReactiveFormsModule]
131
+ })
132
+ export class ToggleswitchReactiveformsDemo {
133
+ messageService = inject(MessageService);
134
+ exampleForm: FormGroup | undefined;
135
+ formSubmitted: boolean = false;
136
+
137
+ constructor() {
138
+ this.exampleForm = this.fb.group({
139
+ activation: ['', Validators.required]
140
+ });
141
+ }
142
+
143
+ onSubmit() {
144
+ this.formSubmitted = true;
145
+ if (this.exampleForm.valid) {
146
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
147
+ this.exampleForm.reset();
148
+ this.formSubmitted = false;
149
+ }
150
+ }
151
+
152
+ isInvalid(controlName: string) {
153
+ const control = this.exampleForm.get(controlName);
154
+ return control?.invalid && (control.touched || this.formSubmitted);
155
+ }
156
+ }
157
+ ```
158
+
159
+ ## Template
160
+
161
+ The handle template is available to display custom content.
162
+
163
+ ```typescript
164
+ import { Component } from '@angular/core';
165
+ import { FormsModule } from '@angular/forms';
166
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
167
+
168
+ @Component({
169
+ template: `
170
+ <div class="card flex justify-center gap-4">
171
+ <p-toggleswitch [(ngModel)]="checked">
172
+ <ng-template #handle let-checked="checked">
173
+ <i [ngClass]="['!text-xs', 'pi', checked ? 'pi-check' : 'pi-times']"></i>
174
+ </ng-template>
175
+ </p-toggleswitch>
176
+ </div>
177
+ `,
178
+ standalone: true,
179
+ imports: [ToggleSwitchModule, FormsModule]
180
+ })
181
+ export class ToggleswitchTemplateDemo {
182
+ checked: boolean = false;
183
+ }
184
+ ```
185
+
186
+ ## templatedrivenforms-doc
187
+
188
+ ```typescript
189
+ import { Component, inject } from '@angular/core';
190
+ import { FormsModule } from '@angular/forms';
191
+ import { MessageModule } from '@exhaustive-ui/core/message';
192
+ import { ToastModule } from '@exhaustive-ui/core/toast';
193
+ import { ToggleSwitchModule } from '@exhaustive-ui/core/toggleswitch';
194
+ import { ButtonModule } from '@exhaustive-ui/core/button';
195
+ import { MessageService } from '@exhaustive-ui/core/api';
196
+
197
+ @Component({
198
+ template: `
199
+ <p-toast />
200
+ <div class="card flex justify-center">
201
+ <form #exampleForm="ngForm" (ngSubmit)="onSubmit(exampleForm)" class="flex flex-col gap-4 w-48">
202
+ <div class="flex flex-col items-center gap-2">
203
+ <p-toggleswitch #model="ngModel" [(ngModel)]="checked" name="activation" [invalid]="model.invalid && exampleForm.submitted" required />
204
+ @if (model.invalid && exampleForm.submitted) {
205
+ <p-message severity="error" size="small" variant="simple">Activation is required.</p-message>
206
+ }
207
+ </div>
208
+ <button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
209
+ </form>
210
+ </div>
211
+ `,
212
+ standalone: true,
213
+ imports: [MessageModule, ToastModule, ToggleSwitchModule, ButtonModule, FormsModule]
214
+ })
215
+ export class ToggleswitchTemplatedrivenformsDemo {
216
+ messageService = inject(MessageService);
217
+ checked: boolean;
218
+
219
+ onSubmit(form: any) {
220
+ if (form.valid) {
221
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 });
222
+ form.resetForm();
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## Pass Through Options
229
+
230
+ | Name | Type | Description |
231
+ |------|------|-------------|
232
+ | root | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the root's DOM element. |
233
+ | input | PassThroughOption<HTMLInputElement, I> | Used to pass attributes to the input's DOM element. |
234
+ | slider | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the slider's DOM element. |
235
+ | handle | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the handle's DOM element. |
236
+
237
+ ## Theming
238
+
239
+ ### CSS Classes
240
+
241
+ | Class | Description |
242
+ |-------|-------------|
243
+ | p-toggleswitch | Class name of the root element |
244
+ | p-toggleswitch-input | Class name of the input element |
245
+ | p-toggleswitch-slider | Class name of the slider element |
246
+
247
+ ### Design Tokens
248
+
249
+ | Token | CSS Variable | Description |
250
+ |-------|--------------|-------------|
251
+ | toggleswitch.width | --p-toggleswitch-width | Width of root |
252
+ | toggleswitch.height | --p-toggleswitch-height | Height of root |
253
+ | toggleswitch.border.radius | --p-toggleswitch-border-radius | Border radius of root |
254
+ | toggleswitch.gap | --p-toggleswitch-gap | Gap of root |
255
+ | toggleswitch.shadow | --p-toggleswitch-shadow | Shadow of root |
256
+ | toggleswitch.focus.ring.width | --p-toggleswitch-focus-ring-width | Focus ring width of root |
257
+ | toggleswitch.focus.ring.style | --p-toggleswitch-focus-ring-style | Focus ring style of root |
258
+ | toggleswitch.focus.ring.color | --p-toggleswitch-focus-ring-color | Focus ring color of root |
259
+ | toggleswitch.focus.ring.offset | --p-toggleswitch-focus-ring-offset | Focus ring offset of root |
260
+ | toggleswitch.focus.ring.shadow | --p-toggleswitch-focus-ring-shadow | Focus ring shadow of root |
261
+ | toggleswitch.border.width | --p-toggleswitch-border-width | Border width of root |
262
+ | toggleswitch.border.color | --p-toggleswitch-border-color | Border color of root |
263
+ | toggleswitch.hover.border.color | --p-toggleswitch-hover-border-color | Hover border color of root |
264
+ | toggleswitch.checked.border.color | --p-toggleswitch-checked-border-color | Checked border color of root |
265
+ | toggleswitch.checked.hover.border.color | --p-toggleswitch-checked-hover-border-color | Checked hover border color of root |
266
+ | toggleswitch.invalid.border.color | --p-toggleswitch-invalid-border-color | Invalid border color of root |
267
+ | toggleswitch.transition.duration | --p-toggleswitch-transition-duration | Transition duration of root |
268
+ | toggleswitch.slide.duration | --p-toggleswitch-slide-duration | Slide duration of root |
269
+ | toggleswitch.background | --p-toggleswitch-background | Background of root |
270
+ | toggleswitch.disabled.background | --p-toggleswitch-disabled-background | Disabled background of root |
271
+ | toggleswitch.hover.background | --p-toggleswitch-hover-background | Hover background of root |
272
+ | toggleswitch.checked.background | --p-toggleswitch-checked-background | Checked background of root |
273
+ | toggleswitch.checked.hover.background | --p-toggleswitch-checked-hover-background | Checked hover background of root |
274
+ | toggleswitch.handle.border.radius | --p-toggleswitch-handle-border-radius | Border radius of handle |
275
+ | toggleswitch.handle.size | --p-toggleswitch-handle-size | Size of handle |
276
+ | toggleswitch.handle.background | --p-toggleswitch-handle-background | Background of handle |
277
+ | toggleswitch.handle.disabled.background | --p-toggleswitch-handle-disabled-background | Disabled background of handle |
278
+ | toggleswitch.handle.hover.background | --p-toggleswitch-handle-hover-background | Hover background of handle |
279
+ | toggleswitch.handle.checked.background | --p-toggleswitch-handle-checked-background | Checked background of handle |
280
+ | toggleswitch.handle.checked.hover.background | --p-toggleswitch-handle-checked-hover-background | Checked hover background of handle |
281
+ | toggleswitch.handle.color | --p-toggleswitch-handle-color | Color of handle |
282
+ | toggleswitch.handle.hover.color | --p-toggleswitch-handle-hover-color | Hover color of handle |
283
+ | toggleswitch.handle.checked.color | --p-toggleswitch-handle-checked-color | Checked color of handle |
284
+ | toggleswitch.handle.checked.hover.color | --p-toggleswitch-handle-checked-hover-color | Checked hover color of handle |
285
+