Switch Group
1.19.0Groups related switches with a shared label, hint text, and validation state.
import {SwitchGroupModule} from "@qualcomm-ui/angular/switch-group"Examples
Simple
Use the simple API to create a switch group using minimal markup.
If you omit the label, you should provide an aria-label to keep your group accessible.
<fieldset hint="Select at least one" label="Notifications" q-switch-group>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
<label label="Push" q-switch></label>
</fieldset>
Composite
The composite API exposes FieldGroup directives for granular control over the group structure.
<fieldset q-field-group-root>
<legend q-field-group-label>Notifications</legend>
<div q-field-group-items>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
<label label="Push" q-switch></label>
</div>
<div q-field-group-hint>Select at least one</div>
</fieldset>
Size
The size input controls the size of child switches. Available sizes are sm, md (default), and lg.
import {Component} from "@angular/core"
import {SwitchModule} from "@qualcomm-ui/angular/switch"
import {SwitchGroupModule} from "@qualcomm-ui/angular/switch-group"
@Component({
imports: [SwitchGroupModule, SwitchModule],
selector: "switch-group-size-demo",
template: `
<div class="flex flex-row gap-8">
<fieldset label="Small" q-switch-group size="sm">
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
</fieldset>
<fieldset label="Medium" q-switch-group size="md">
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
</fieldset>
<fieldset label="Large" q-switch-group size="lg">
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
</fieldset>
</div>
`,
})
export class SwitchGroupSizeDemo {}Orientation
Use the orientation input to control the layout direction of the group. Options include:
vertical: switches are laid out in a column (default).horizontal: switches are laid out in a row.
<fieldset label="Notifications" orientation="horizontal" q-switch-group>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
<label label="Push" q-switch></label>
</fieldset>
Indented
Set indented to add padding at the start of the group.
<fieldset indented label="Notifications" q-switch-group>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
<label label="Push" q-switch></label>
</fieldset>
Hint
Use hint to add additional guidance or context to the user below the group.
<fieldset hint="Select at least one" label="Notifications" q-switch-group>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
<label label="Push" q-switch></label>
</fieldset>
Error Text
Set invalid and errorText to display validation errors. The error text replaces the hint when present.
<fieldset
errorText="Select at least one option"
invalid
label="Notifications"
q-switch-group
>
<label label="Email" q-switch></label>
<label label="SMS" q-switch></label>
</fieldset>
Explorer
API
q-switch-group
The q-switch-group directive extends q-field-group-root with the following inputs:
Composite API
q-field-group-root
<fieldset> element.booleanboolean| 'vertical'
| 'horizontal'
| 'sm'
| 'md'
| 'lg'
class'qui-field-group__root'data-field-group-part'root'data-invalidq-field-group-label
<legend> element inside a fieldset.class'qui-field-group__label'data-field-group-part'label'q-field-group-items
class'qui-field-group__items'data-field-group-part'items'data-indenteddata-orientation| 'vertical'
| 'horizontal'
data-size| 'sm'
| 'md'
| 'lg'
q-field-group-hint
class'qui-field-group__hint'data-field-group-part'hint'q-field-group-error-text
| LucideIconData
| string
class'qui-field-group__error-text'data-field-group-part'error-text'