ThiloDesign System
DV

Toggle

shadcn/ui
2 variants

Single on/off button that remembers its pressed state. Like a stateful icon button.

@/components/ui/toggle

Variants

VariantOffOn (pressed)Pressed token
defaultdata-[state=on]: bg-accent text-accent-foreground
outlineadds border-border; same pressed bg-accent

States

StatePreviewToken
Off (default)bg-transparent — no background
On (pressed)bg-accent text-accent-foreground
Hoverhover:bg-muted hover:text-muted-foreground
Disabled offopacity-50 pointer-events-none
Disabled onopacity-50 pointer-events-none

Sizes

lg · 40px
default · 36px
sm · 32px

With text

In context — formatting toolbar

Italic is pressed (defaultPressed). Toggle size="sm" matches the toolbar density.

Toggle vs Switch

ToggleSwitch
ShapeButton (rectangular)Pill / slider thumb
ContextToolbars, editing actions, view modesSettings, feature flags, notifications
LabelIcon or icon+text (brief)Full sentence description

Props

PropTypeDescription
variant"default" | "outline"Visual style of the toggle
size"sm" | "default" | "lg"Height and padding
pressedbooleanControlled pressed state
defaultPressedbooleanInitial pressed state (uncontrolled)
onPressedChangefunction(pressed: boolean) => void
disabledbooleanPrevents interaction, reduces opacity
aria-labelstringRequired for icon-only toggles — describes the action

On this page