Native Web Components playground

Nova v3.37.0

Preview

Web Components

Toggle button group

nv-togglebuttongroup

Holds a set of toggle buttons and their selected values.

Parts

Live demo

Emphasis
Size

A toggle button group joins toggle buttons and keeps the selected values as a string array in value; each button's value names its option.

  • exclusive allows one choice; without it, several buttons can be selected.
  • enforceValue keeps at least one button selected.
  • emphasis and size apply to every button in the group.
  • Bind value and listen for valueChanged. Name the group with role="group" and an aria-label.

Anatomy

The toggle button anatomy shows text and icon-only buttons together in a group.

Appearance and states

This component implements the grouping described on the Togglegroup design page. Its child toggle buttons can use text, icons or both in their default slot. Use the same emphasis (high or low) and size (xs, sm, md or lg) throughout the group.

Spark and Ocean provide default, hover, focus, selected and disabled styles. Set disabled on individual children when those options are unavailable; the group has no group-wide disabled prop. Keep each option's label and focus indicator clear, including an aria-label for an icon-only toggle.

Selection guidance

Use exclusive for mutually exclusive views, such as list or grid. Leave it off for independent choices, such as several text-formatting options. Set enforceValue when clearing the last choice would leave an invalid state. The group updates the children's active state from its value array; consumers should bind that array instead of independently setting child selection. Choose labels that describe the state being turned on.

Sources