Skip to main content

Switch

Demo

zeta-web v0.6.6
Web Components

Switches toggle the state of a single item ON or OFF. To use with icon variant, provide both activeIcon and inactiveIcon

Storybook

https://design.zebra.com/web/storybook/?path=/docs/components-switch--docs

Attributes

NameDescriptionTypeDefault
activeIconIcon name to display when switch is ON.ZetaIconName | undefinedundefined
inactiveIconIcon name to display when switch is OFF.ZetaIconName | undefinedundefined

Inherited Attributes

NameDescriptionTypeDefaultInherited From
autoCapitalizeWhether inputted text is automatically capitalized and how. Only takes effect on non-keyboard entry"none" | "off" | "sentences" | "on" | "words" | "characters" | undefinedundefinedBaseToggleFormElement
autoCompleteAutoFill | undefinedundefinedBaseToggleFormElement
nameThe name of the form control.string""BaseToggleFormElement
idThe id of the form control.string""BaseToggleFormElement
requiredIndicates whether the form control is required to be filled out before submitting the form.booleanfalseBaseToggleFormElement
valueThe value of the Form Control that is submitted when part of a form.string | nullnullBaseToggleFormElement
checkedThe state of the Switch or Checkbox that is submitted when part of a form.booleanundefinedBaseToggleFormElement
indeterminateThe state of the Switch or Checkbox defined by a mixed or unknown state.booleanfalseBaseToggleFormElement
placeholderPlaceholder text shown when value is empty.string | undefinedundefinedBaseToggleFormElement
minThe minimum value for number inputsnumber | undefinedundefinedBaseToggleFormElement
maxThe maximum value for number inputsnumber | undefinedundefinedBaseToggleFormElement
readOnlyPlaceholder text shown when value is empty.boolean | undefinedundefinedBaseToggleFormElement
spellCheckWhether to spellcheck the inputboolean | "default" | undefinedundefinedBaseToggleFormElement
disabledBoolean for if component is disabled.This will apply disabled styles.booleanfalseBaseToggleFormElement
tabIndexThe tab index of the component, used to determine the order in which elements receive focus when the user navigates through the document by pressing the Tab key.number0BaseToggleFormElement
roundedWhether the component is rounded or sharp.When true, rounded will set the border radius of the first child, and any children with class 'contourable-target' to --radius-minimal.Otherwise, this value will be --radius-none.boolean | undefinedtrueBaseToggleFormElement

CSS Properties

NameDescription
--switch-track-colorColor of the switch track
--switch-track-active-colorColor of the switch track when switch is ON
--switch-track-disabled-colorColor of the switch track when switch is disabled
--switch-icon-colorColor of the activeIcon & inactiveIcon
--switch-icon-disabled-colorColor of the activeIcon & inactiveIcon when disabled
--switch-thumb-colorColor of the switch thumb
--switch-thumb-disabled-colorColor of the switch thumb when disabled
--switch-heightHeight of the switch
--switch-widthWidth of the switch
--switch-thumb-sizeHeight & Width of the switch thumb
--switch-icon-sizeHeight & Width of the activeIcon & inactiveIcon

Figma

https://www.figma.com/design/JesXQFLaPJLc1BdBM4sisI/%F0%9F%A6%93-ZDS---Components?node-id=23105-92337