ComponentsToggle

Toggle

A simple toggle switch component




The Toggle component is a simple switch that can be toggled on or off. It is commonly used to enable or disable a feature or setting.

Tip!

Use icon prop to display an icon inside the toggle switch.




Props

The Toggle component accepts the following props:

NameTypeDefaultDescription
checkedbooleanfalseWhether the toggle switch is checked or not
onChangefunctionCallback function to handle the toggle switch change event
classNamestringCustom CSS classes to apply to the toggle switch
labelstringLabel text to display next to the toggle switch
labelPositionstringleftPosition of the label relative to the toggle switch ('left' or 'right')
colorstringprimaryThe color scheme of the toggle switch
iconbooleanfalseWhether to display an icon inside the toggle switch
focusbooleanfalseWhether to apply a focus ring effect when the toggle switch is focused
disabledbooleanfalseWhether the toggle switch is disabled or not

Info

The onChange prop is required to handle the toggle switch change event.


Usage Examples

Basic Toggle

Toggle with Label

Toggle with Icon

Disabled Toggle

Customized Toggle