Switch
A toggle between two states, such as on and off.
A Switch lets users toggle between two states, such as on and off. It is
typically used for settings or preferences and gives immediate visual feedback.
import { Switch } from '@workflowbuilder/ui';import { useState } from 'react';
function Example() { const [checked, setChecked] = useState(false); return <Switch checked={checked} onChange={(next) => setChecked(next)} />;}checkedWhether the switch is checked or not
classNameCustom class name for the switch component
disabledWhether the switch is disabled
onChangeCallback function when the switch state changes
sizeSize of the switch component
thumbChildrenCustom content for the thumb of the switch
trackChildrenCustom content for the track of the switch
CSS variables
Section titled “CSS variables”Color
--wb-public-switch-outline-color--wb-public-switch-disabled-background-color--wb-public-switch-disabled-border-color--wb-public-track-no-selected-color--wb-public-track-selected-color--wb-public-thumb-no-selected-color--wb-public-thumb-disabled-color--wb-public-thumb-selected-color--wb-public-switch-focus-border-colorSize
--wb-public-switch-width-medium--wb-public-switch-height-medium--wb-public-switch-thumb-padding-medium--wb-public-switch-width-small--wb-public-switch-height-small--wb-public-switch-thumb-padding-small--wb-public-switch-width-extra-small--wb-public-switch-height-extra-small--wb-public-switch-thumb-padding-extra-small--wb-public-switch-border-sizeIcon switch
Section titled “Icon switch”IconSwitch is a Switch variant that swaps a track icon and a thumb icon
based on the checked state, for representing on/off states with icons instead
of a bare thumb.
import { Moon, Sun } from '@phosphor-icons/react';import { IconSwitch } from '@workflowbuilder/ui';import { useState } from 'react';
function Example() { const [checked, setChecked] = useState(false); return <IconSwitch checked={checked} icon={<Sun />} IconChecked={<Moon />} onChange={(next) => setChecked(next)} />;}IconCheckedrequiredcheckedWhether the switch is checked or not
classNameCustom class name for the switch component
disabledWhether the switch is disabled
iconIcon the component shows; `IconSwitch` shows it in the off state.
onChangeCallback function when the switch state changes
sizeSize of the switch component
thumbChildrenCustom content for the thumb of the switch
trackChildrenCustom content for the track of the switch
variantCSS variables
Section titled “CSS variables”Color
--wb-public-icon-switch-track-bg--wb-public-icon-switch-thumb-bg-primary--wb-public-icon-switch-icon-color--wb-public-icon-switch-icon-selected-color--wb-public-icon-switch-thumb-bg-secondarySize
--wb-public-icon-switch-width--wb-public-icon-switch-height--wb-public-icon-switch-thumb-size--wb-public-icon-switch-thumb-offset--wb-public-icon-switch-translate--wb-public-icon-switch-padding--wb-public-icon-switch-icon-size