Skip to content

ToggleGroup

Group of toggles with shared state management.

Also known as: switch group, toggle list, multi-toggle

View in Storybook

When to use

  • Selecting multiple options as on/off toggles (feature flags, notification preferences). For checkbox groups, use CheckboxGroup.
  • For card-style toggles, use ToggleCard.

Import

tsx
import { ToggleGroup } from '@vacano/ui'

Usage

tsx
const [values, setValues] = useState(['email'])

const options = [
  { value: 'email', label: 'Email' },
  { value: 'sms', label: 'SMS' },
  { value: 'push', label: 'Push' },
]

<ToggleGroup
  options={options}
  value={values}
  onChange={setValues}
/>

With Label

tsx
<ToggleGroup
  label="Notifications"
  options={options}
  value={values}
  onChange={setValues}
/>

Variants

tsx
<ToggleGroup variant="normal" options={options} value={[]} onChange={() => {}} />
<ToggleGroup variant="error" options={options} value={[]} onChange={() => {}} />

Disabled

tsx
<ToggleGroup
  disabled
  options={options}
  value={['email']}
  onChange={() => {}}
/>

Props

PropTypeDefaultDescription
optionsToggleGroupOption[]requiredArray of options
valuestring[]requiredSelected values
onChange(values: string[]) => voidrequiredChange handler
labelstring-Group label
variant'normal' | 'error''normal'Visual variant for all toggles
disabledbooleanfalseDisable all toggles
classNamestring-CSS class for root element
classnamesToggleGroupClassNames-Custom class names for inner elements
refRef<HTMLDivElement>-Ref to the root container element
data-test-idstring-Test identifier for automated testing

Option Type

tsx
type ToggleGroupOption = {
  label: string
  value: string
}

ClassNames

KeyDescription
labelGroup label
optionsOptions container
toggleIndividual toggle

Released under the MIT License.