KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Navigation

kt-toggle-button-group

GitHub Copy link

Joins <kt-toggle-button>s into one bar and owns their selection.

Preview

List Grid Map

Joins <kt-toggle-button>s into one bar and owns their selection.

<kt-toggle-button-group label="View"> <kt-toggle-button value="list">List</kt-toggle-button> <kt-toggle-button value="grid">Grid</kt-toggle-button> <kt-toggle-button value="map">Map</kt-toggle-button> </kt-toggle-button-group>group.addEventListener('kt-change', (e) => console.log(e.detail.value));

The group owns the selection

Buttons are slotted rather than described by an options array, so a label can be anything — an icon, a count, a badge.

Inside a group a button becomes controlled: it no longer flips itself and no longer emits. The group reads the click, works out what the selection now is, and writes selected back down. That is what keeps one press from producing two contradictory kt-change events.

So: listen on the group, never on its buttons.

Single and multiple

Single mode behaves like a radio group with a deselect — pressing the active button clears it, and value is a string or null.

multiple makes it a set of checkboxes drawn together, and value becomes an array.

<kt-toggle-button-group multiple orientation="vertical"></kt-toggle-button-group>

Corner rounding belongs to the group, which is the only thing that knows which button is first and which is last; it drives --kt-toggle-button-radius on each child through CSS.

API

PropertyAttributeTypeDefault
value—string | string[] | nullnull
multiplemultiplebooleanfalse
orientationorientation'horizontal' | 'vertical''horizontal'
labellabelstring''
EventDetail
kt-change{ value }
SlotDescription
default<kt-toggle-button> children
PartDescription
baseThe group container

See <kt-toggle-button> for the button itself.