Skip to content

Switch Group

A group of switch components that allows users to toggle multiple related options. It supports both single and multiple selection modes.

Component Features

  • 🔄 Multiple Modes: Supports both single and multiple selection modes.
  • 🎛️ Bulk Operations: Provides built-in methods for selectAll and clearAll in multiple selection mode.
  • 📐 Direction Control: Can be arranged horizontally (row) or vertically (column).
  • 📋 Form & Table Integration: Easily integrates with BrForm and BrTable components.
  • 🎨 Size Inheritance: Automatically inherits sizes from global configurations or props, and passes them to child switch items.

Basic Usage

The basic usage of SwitchGroup with mode switching and bulk operations.

当前值: [ "wifi", "bluetooth" ]
Example

Form Integration

Typical application in form operations for preference settings.

Example

Table Integration

Used within a table to manage list item permissions or statuses.

用户
权限设置
User 1
User 2
Example

API Reference

BrSwitchGroup

PropTypeDefaultDescription
modelValue (v-model)string | number | (string | number)[] | undefined-The selected value(s)
mode'single' | 'multiple''multiple'Selection mode
disabledbooleanfalseWhether the entire group is disabled
direction'row' | 'column''row'Layout direction
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'default'-Size of the switches
lazyRenderbooleanfalseWhether to lazily render the group

Methods

NameDescription
selectAllSelects all available options (only available in multiple mode)
clearAllClears all selections

BrSwitchGroupItem

PropTypeDefaultDescription
valuestring | number-Unique value for the item (Required)
labelstring-Text label for the switch
disabledbooleanfalseWhether the item is disabled
checkedTextstring-Text to display when checked
uncheckedTextstring-Text to display when unchecked
loadingbooleanfalseWhether the item is in a loading state