ComponentsSwitch

Switch

A customizable switch component for toggling between states




The Switch component is a versatile toggle switch that can be used switch between different states.

Tip!

Use shape prop to change the shape of the switch. The available options are rounded-full, rounded-lg, and rounded-none.

Warning!

Ensure that the options prop is an array of objects with name and value properties.




Props

The Switch component accepts the following props:

NameTypeDefaultDescription
optionsarrayAn array of objects with name and value properties.
selectedstringThe value of the selected option.
onChangefunctionA function that is called when an option is selected.
activeColorstringgrayThe color of the selected option.
inactiveColorstringgrayThe color of the unselected options.
activeBgColorstringbgThe background color of the selected option.
inactiveBgColorstringbgThe background color of the unselected options.
hoverbooleanfalseWhether to apply hover styles to the options.
tooltipbooleanfalseWhether to show tooltips on hover.
verticalbooleanfalseWhether to display the options vertically.
shapestringrounded-fullThe shape of the switch. Possible values: rounded-full, rounded-lg, rounded-none.
classNamestringAdditional CSS classes to be applied to the switch container.


Usage Examples

Basic Switch

Custom Colors

Vertical Switch

Switch with Tooltips