Switch
A control that allows the user to toggle between checked and not checked.
Component Features
- 🔄 Toggle Control: Allows switching between checked and unchecked states.
- 📏 Multiple Sizes: Supports
sm,md,lgsize specs. - ⏳ Loading State: Supports
loadingprop to display loading animation. - ❌ Disabled State: Supports
disabledprop. - 📝 Status Text: Supports custom status text via
checked-textandunchecked-textprops. - 🎨 Custom Thumb: Supports custom thumb content via
thumbslot. - 🎨 Theme Customization: Based on
BrConfigProviderfor global theming and TailwindCSS local overrides.
Basic Usage
Disabled State
Set the disabled prop to disable the switch.
Loading State
Set the loading prop to show a loading state. The switch is disabled while loading.
With Label
Use BrLabel to associate a label with the switch.
Sizes
Use the size prop to control the size of the switch.
Custom Thumb Content
You can customize the content inside the switch thumb using the thumb slot, such as adding icons or text.
Theming
Global Customization (BrConfigProvider)
You can override default CSS variables via the theme prop of BrConfigProvider.
Local Customization (TailwindCSS)
You can directly override styles using TailwindCSS utility classes.