Switch Group
Groups toggle switches under one label and sets their size and disabled state together. Lays them out vertically or horizontally.
<arc-switch-group>Overview
SwitchGroup puts a set of arc-toggle elements in a native <fieldset>, with label as its <legend>. It copies its size and disabled to each toggle, so you set them once.
orientation="vertical" (the default) stacks the toggles in a column, for settings panels and forms. horizontal puts them in a wrapping row with wider gaps, for a compact row of options.
Guidelines
Do
- Use it for related on/off settings, such as notification preferences
- Set `label` to say what the toggles control
Don't
- Don't mix in children other than `arc-toggle`. Only toggles get the shared size and disabled state
- Don't use it for mutually exclusive options. Use RadioGroup
Features
- The toggles sit in a `role="group"` labelled by `label`
- A disabled group is dimmed to 50% opacity
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-switch-group label="Notifications">
<arc-toggle label="Email" checked></arc-toggle>
<arc-toggle label="Push"></arc-toggle>
<arc-toggle label="SMS"></arc-toggle>
</arc-switch-group>
<!-- Horizontal layout -->
<arc-switch-group label="Features" orientation="horizontal">
<arc-toggle label="Dark mode" checked></arc-toggle>
<arc-toggle label="Compact view"></arc-toggle>
</arc-switch-group>import { SwitchGroup, Toggle } from '@arclux/arc-ui-react';
export default function Example() {
return (
<SwitchGroup label="Notifications">
<Toggle label="Email" checked />
<Toggle label="Push" />
<Toggle label="SMS" />
</SwitchGroup>
);
}<script setup>
import { SwitchGroup, Toggle } from '@arclux/arc-ui-vue';
</script>
<template>
<SwitchGroup label="Notifications">
<Toggle label="Email" checked />
<Toggle label="Push" />
<Toggle label="SMS" />
</SwitchGroup>
</template><script>
import { SwitchGroup, Toggle } from '@arclux/arc-ui-svelte';
</script>
<SwitchGroup label="Notifications">
<Toggle label="Email" checked />
<Toggle label="Push" />
<Toggle label="SMS" />
</SwitchGroup>import { Component } from '@angular/core';
import { SwitchGroup, Toggle } from '@arclux/arc-ui-angular';
@Component({
imports: [SwitchGroup, Toggle],
template: `
<arc-switch-group label="Notifications">
<arc-toggle label="Email" checked />
<arc-toggle label="Push" />
<arc-toggle label="SMS" />
</arc-switch-group>
`,
})
export class SettingsPanel {}import { SwitchGroup, Toggle } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<SwitchGroup label="Notifications">
<Toggle label="Email" checked />
<Toggle label="Push" />
<Toggle label="SMS" />
</SwitchGroup>
);
}import { SwitchGroup, Toggle } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<SwitchGroup label="Notifications">
<Toggle label="Email" checked />
<Toggle label="Push" />
<Toggle label="SMS" />
</SwitchGroup>
);
}API
labelstring''- Group heading rendered as a
<legend>element. orientation'vertical' | 'horizontal''vertical'- Layout direction. Vertical stacks toggles, horizontal arranges them in a row.
size'sm' | 'md' | 'lg''md'- Size cascaded to all child arc-toggle elements.
disabledbooleanfalse- Disables all child toggles and dims the group.
See also
- ToggleAn on/off switch for a setting that takes effect at once.
- FieldsetGroups related form controls in a native fieldset with a legend, drawn as a bordered box or a card.
- CheckboxA checkbox with a built-in label and an indeterminate state for "select all" boxes.
- Radio GroupA set of radio options, all visible at once, where exactly one can be chosen.