StartFoundationsComponentsContent

Toggle button group

A toggle button group joins several toggle buttons into one toolbar, where any number can be on at once.

Stable Figma
OverviewUsageAPIAccessibility
Bold Italic Underline
<tk-toggle-button-group label="Text formatting">
  <tk-toggle-button value="bold" pressed><tk-button variant="ghost">Bold</tk-button></tk-toggle-button>
  <tk-toggle-button value="italic"><tk-button variant="ghost">Italic</tk-button></tk-toggle-button>
  <tk-toggle-button value="underline"><tk-button variant="ghost">Underline</tk-button></tk-toggle-button>
</tk-toggle-button-group>

Anatomy

Part What it is
tk-toggle-button-group the element; role="toolbar"; one Tab stop for the whole group
default slot two or more tk-toggle-button, each with a value
end caps and seams the same joined geometry as a Button group

Layout

The group lays out its toggles exactly like a Button group.

  • Joined (default) or spaced: one block with a 1px line between toggles, or separate toggles with an 8px gap.
  • orientation="vertical": a column; the arrow keys follow it.
  • shape="round": pill end caps, or 16px caps on a vertical block. Set it on the group, not on the inner buttons.
Unread Starred Mentions
<tk-toggle-button-group shape="round" label="Filters">
  <tk-toggle-button value="unread" pressed><tk-button>Unread</tk-button></tk-toggle-button>
  <tk-toggle-button value="starred"><tk-button>Starred</tk-button></tk-toggle-button>
  <tk-toggle-button value="mentions" pressed><tk-button>Mentions</tk-button></tk-toggle-button>
</tk-toggle-button-group>

Sizes

Set size once on the group and every toggle takes it: small, medium, or large, 24, 32, or 36px tall, like Button.

Grid lines Rulers
<tk-toggle-button-group size="small" label="View">
  <tk-toggle-button value="grid"><tk-button>Grid lines</tk-button></tk-toggle-button>
  <tk-toggle-button value="rulers"><tk-button>Rulers</tk-button></tk-toggle-button>
</tk-toggle-button-group>

States

Snap Guides
<tk-toggle-button-group disabled label="Alignment guides">
  <tk-toggle-button value="snap" pressed><tk-button>Snap</tk-button></tk-toggle-button>
  <tk-toggle-button value="guides"><tk-button>Guides</tk-button></tk-toggle-button>
</tk-toggle-button-group>
  • disabled: disables every toggle, and the group drops out of the Tab order. A toggle you disabled on its own stays disabled when the group is enabled again.
  • Each toggle's on state and look come from Toggle button.

Value

  • value is a property holding the array of the pressed toggles' values, such as ["bold", "underline"]. Setting it presses exactly those toggles.
  • change fires once each time a user flips a toggle. Read event.target.value. Setting value or pressed in code fires nothing.