Material Design 3 segmented button web components (lit-material-segmented-button-group, lit-material-segmented-button).
2.8 KB gzipped
@lit-material/segmented-button 0.1.0
Renders on the server
Example
Segmented Button
A connected row of toggleable segments — single-select (radio-like) by default, or
multiselect (checkbox-like). Arrow keys move a roving tabindex; Enter/Space
activates.
Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide
API
<lit-material-segmented-button-group>
Material Design 3 segmented buttons — a connected row of
lit-material-segmented-button elements, in either single-select
(multiselect false, the default — exactly one segment selected at a
time, like a radio group) or multi-select (multiselect true — any number
of segments selected independently, like a group of checkboxes) mode.
Properties
Property
Attribute
Type
Default
Description
multiselect
multiselect
boolean
false
When true, any number of segments may be selected at once (checkbox-like). Defaults to false (radio-like: exactly one at a time).
Events
Event
Description
change
Fires when a segment's selected state changes via user interaction.
Slots
Slot
Description
default
lit-material-segmented-button elements.
<lit-material-segmented-button>
A single segment within lit-material-segmented-button-group. Purely
presentational — like lit-material-tab, it has no click handler of its
own; the parent group listens for the bubbling click (via
event.composedPath(), the same delegation pattern lit-material-tabs
uses) and drives selected and the roving tabindex (active) from there.
Properties
Property
Attribute
Type
Default
Description
selected
selected
boolean
false
>
disabled
disabled
boolean
false
>
active
property only
boolean
false
Whether this segment currently holds the group's roving tabindex.
Entirely managed by the parent group — don't set it directly.
Slots
Slot
Description
default
The segment's label.
icon
An optional icon shown before the label. Ignored on a selected segment, which shows a checkmark in its place — the same leading-icon/checkmark swap lit-material-chip's filter variant makes.
CSS parts
Part
Description
button
The button (background/padding).
ripple
The state-layer element the hover/press feedback is drawn on.