• Docs
  • Components
  • Switch

Switch - Aspect UI

The Switch component toggles between two states such as on/off. It’s a user-friendly alternative to checkboxes, often used in settings or preferences.

Table of Contents#

Switch Props#


PropTypeDefaultDescription
checkedboolean-Whether the switch is currently on (true) or off (false).
onChange(checked: boolean) => void-Callback function triggered when the switch state changes.
disabledbooleanfalseDisables the switch when set to true.
labelstring-Optional label text displayed next to the switch.
sizesmall medium large'medium'Determines the size of the switch.
classNamestring''Additional CSS class for the root container.
switchClassNamestring''Custom CSS class applied to the switch element.
activeClassNamestring''CSS class applied to the active (checked) state container.
deactiveClassNamestring''CSS class applied to the inactive (unchecked) state container.
activeSwitchClassNamestring''CSS class applied to the switch knob when active.
deactiveSwitchClassNamestring''CSS class applied to the switch knob when inactive.
labelClassNamestring''CSS class applied to the label element.
switchIconEnabledbooleantrueIf true, shows the active and inactive switch icons.
activeSwitchIconReact.ReactNode-Icon displayed inside the switch knob when active.
deactiveSwitchIconReact.ReactNode-Icon displayed inside the switch knob when inactive.