eds-switch

Explore the Interactive Component

Use the playground below to experiment with the component. Click the button to view the full Storybook deployment for additional examples and configurations.

eds-switch Open in Storybook

See It in Use with Code

Check out this practical implementation of component.

Plain HTML

In React

Segmented Variant with Options

Pass two or more options (an array, or a JSON string in HTML) and a variant of segmented, segmented-dark or segmented-light to render one segment per option. value holds the selected option. The toggle emits uiswitch ({ value: boolean }); with options the component emits uiselect ({ value: string }) instead.

Properties

PropertyAttributeDescriptionTypeDefault
checkedcheckedIndicates whether the switch is checked.booleanfalse
disableddisabledDisables the switch if true.booleanfalse
fullWidthfull-widthSegments share the full width in equal parts (e.g. on phones).booleanfalse
groupLabelgroup-labelAccessible name of the group of segments.string'View toggle'
labelOfflabel-offLabel to display when the switch is OFF.string''
labelOnlabel-onLabel to display when the switch is ON.string''
optionsoptionsTwo or more choices instead of on/off: [{ value, label, title? }], as an array or a JSON string. With options the switch renders one segment each (in the segmented look of variant) and emits uiselect.string | { value: string; label: string; title?: string; }[]''
sizesizeSegment size for the segmented variants: ‘medium’ (default) stands 44px tall, level with EDS inputs and large buttons (Forms’ AI builder switch); ‘small’ is the compact one."medium" | "small"'medium'
valuevalueThe selected option’s value, when options is set.string''
variantvariantVariant of the switch: - ’toggle’ (default): the classic on/off switch - ‘segmented’: pill-style buttons — light container, green active pill - ‘segmented-dark’: pill-style buttons — white container with a hairline border and a dark (brand-black) active pill - ‘segmented-light’: pill-style buttons — light grey track with a hairline border; the active segment is raised in white (Forms’ mode switch)"segmented" | "segmented-dark" | "segmented-light" | "toggle"'toggle'

Events

EventDescriptionType
uiselectEmitted when another option is chosen (with options).CustomEvent<{ value: string; }>
uiswitchEmitted when the switch is toggled.CustomEvent<{ value: boolean; }>

Built with StencilJS