Skip to content

Toggle

<ts-toggle> vv0.4.0

The ts-toggle component.

Open in Storybook for interactive demos.

<ts-toggle size="md">Content</ts-toggle>
PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseWhether the toggle is checked.
disableddisabledbooleanfalseRenders the toggle as disabled.
namenamestring | undefinedName for form submission.
sizesize"lg" | "md" | "sm" | "xl" | "xs"'md'The toggle’s size.
valuevaluestring | undefinedValue for form submission.
EventDetailBubblesComposedDescription
tsChangeTsToggleEventDetailYesYesEmitted when the toggle state changes.
MethodSignatureDescription
toggletoggle() => Promise<void>Programmatically toggle the checked state.
NameDescription
*(default)*Default slot for the toggle label.

Use ::part() to style internal elements:

PartDescription
baseThe toggle container.
labelThe label wrapper.
thumbThe toggle thumb/knob.
trackThe toggle track.
ts-toggle::part(base) {
/* your custom styles */
}
<ts-toggle size="md">Content</ts-toggle>
import { TsToggle } from '@tessera-ui/react';
<TsToggle size="md">Content</TsToggle>