Skip to content
Components

Toggle

Pressed-state button and toggle group built on the Button surface.

Composition

Single toggle

  • <Toggle />

Toggle group

  • <ToggleGroup>
    • <Toggle />
    </ToggleGroup>

Installation

The Control UI source installs this primitive from src/registry/sources/control-ui/ui/toggle.tsx.

Registry command
See registry manifest

Dependencies

Raw code

Primary installed source

src/registry/sources/control-ui/ui/toggle.tsx

Knobs

Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.

--cui-button-radius<length-percentage>var(--nest-radius, var(--radius-control))
--cui-button-gap<length-percentage>calc(var(--spacing) * 1.5)
--cui-button-icon<length>1rem
--cui-button-height<length-percentage>var(--control-h-md)
--cui-button-padding-inline<length-percentage>var(--padding-x)
--cui-button-icon-padding-inline<length-percentage>max(0px, calc(var(--cui-button-padding-inline) - var(--spacing) * 0.5))
--cui-button-font-size<length-percentage>var(--text-body)
--cui-button-background<color>transparent
--cui-button-background-image*none
--cui-button-hover-background-image*var(--cui-button-background-image)
--cui-button-foreground<color>var(--muted-foreground)
--cui-button-hover-background<color>var(--hover-fill)
--cui-button-hover-foreground<color>var(--foreground)
--cui-button-press-background<color>var(--cui-button-hover-background)
--cui-button-press-scale<number>0.96
--cui-button-active-background<color>var(--active-fill)
--cui-button-active-foreground<color>var(--foreground)
--cui-button-active-hover-background<color>var(--cui-button-active-background)
--cui-button-shadow*0 0 transparent
--cui-button-hover-shadow*var(--cui-button-shadow)
--cui-button-press-shadow*var(--cui-button-hover-shadow)
--cui-button-active-shadow*var(--cui-button-shadow)
--cui-button-open-background<color>var(--cui-button-hover-background)
--cui-button-open-foreground<color>var(--cui-button-hover-foreground)
--cui-button-open-shadow*var(--cui-button-shadow)