🚀ReacUI is currently in Beta. We're actively improving it! ❣️
Switch
A toggle switch component for controlling boolean states
Enabled
Installation
The Switch component is part of the ReacUI library. Install the package to use it in your project.
Import
Import the Switch component into your React component.
Basic Usage
The Switch component provides a toggle switch control to manage boolean states.
Switch States
Switches can be in different states such as checked, unchecked, or disabled.
Unchecked
Checked
Disabled (Unchecked)
Disabled (Checked)
Switch Sizes
The Switch component comes in different sizes to fit your design.
Small
Medium (default)
Large
With Label
Add labels to your switches to provide more context.
Get notified once a day with a summary of all activity.
Switch between light and dark theme.
API Reference
The following props are available for the Switch component.
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | false | Whether the switch is checked |
| disabled | boolean | false | Whether the switch is disabled |
| size | enum | 'md' | Size of the switch: 'sm', 'md', or 'lg' |
| onChange | function | - | Callback function that is triggered when the switch state changes |
| id | string | - | The id attribute of the switch |