2.25.0
Button Groups join two or more buttons into a unified control, formerly called a segmented control.
Use to create a mutually exclusive toggle.
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="cyclical--49078">
<input id="cyclical--49078" value="cyclical" class="mds-button__input" type="radio" name="default-html" checked>
<span for="cyclical--49078" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--90458">
<input id="defensive--90458" value="defensive" class="mds-button__input" type="radio" name="default-html">
<span for="defensive--90458" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--48866">
<input id="sensitive--48866" value="sensitive" class="mds-button__input" type="radio" name="default-html">
<span for="sensitive--48866" class="mds-button mds-button--secondary">
Sensitive
</span>
</label>
</div>
<mds-button-group>
<mds-button variation="secondary" type="radio" name="default-mdswc" value="cyclical" checked>Cyclical</mds-button>
<mds-button variation="secondary" type="radio" name="default-mdswc" value="defensive">Defensive</mds-button>
<mds-button variation="secondary" type="radio" name="default-mdswc" value="sensitive">Sensitive</mds-button>
</mds-button-group>
Use when you want the button group to span the full width of its container.
<div class="mds-button-group mds-button-group--justify">
<label class="mds-button__input-outer-wrapper" for="cyclical--83239">
<input id="cyclical--83239" value="cyclical" class="mds-button__input" type="radio" name="full-width-html" checked>
<span for="cyclical--83239" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--41545">
<input id="defensive--41545" value="defensive" class="mds-button__input" type="radio" name="full-width-html">
<span for="defensive--41545" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--1783">
<input id="sensitive--1783" value="sensitive" class="mds-button__input" type="radio" name="full-width-html">
<span for="sensitive--1783" class="mds-button mds-button--secondary">
Sensitive
</span>
</label>
</div>
<mds-button-group full-width>
<mds-button variation="secondary" type="radio" name="full-width-mdswc" value="cyclical" checked>Cyclical</mds-button>
<mds-button variation="secondary" type="radio" name="full-width-mdswc" value="defensive">Defensive</mds-button>
<mds-button variation="secondary" type="radio" name="full-width-mdswc" value="sensitive">Sensitive</mds-button>
</mds-button-group>
type="check"
or type="radio"
on the contained buttons.Use Icons to provide additional affordance to a button.
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="filter--26132">
<input id="filter--26132" value="filter" class="mds-button__input" type="radio" name="with-icons-html" checked>
<span for="filter--26132" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#funnel--s">
</use>
</svg>
<span class="mds-button__text">
Filter
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="upload--42167">
<input id="upload--42167" value="upload" class="mds-button__input" type="radio" name="with-icons-html">
<span for="upload--42167" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#upload--s">
</use>
</svg>
<span class="mds-button__text">
Upload
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="search--58779">
<input id="search--58779" value="search" class="mds-button__input" type="radio" name="with-icons-html">
<span for="search--58779" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#search--s">
</use>
</svg>
<span class="mds-button__text">
Search
</span>
</span>
</label>
</div>
<mds-button-group>
<mds-button icon="funnel--s" variation="secondary" type="radio" name="with-icons-mdswc" value="filter" checked>Filter</mds-button>
<mds-button icon="upload--s" variation="secondary" type="radio" name="with-icons-mdswc" value="upload">Upload</mds-button>
<mds-button icon="search--s" variation="secondary" type="radio" name="with-icons-mdswc" value="search">Search</mds-button>
</mds-button-group>
Icon-only button groups have been deprecated and will be removed in MDS 3.0.0
. To create a group of icon-only buttons, place them within a Button Container.
Button group size is dictated by the Buttons used within.
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="cyclical--50973">
<input id="cyclical--50973" value="cyclical" class="mds-button__input" type="radio" name="html-small" checked>
<span for="cyclical--50973" class="mds-button mds-button--secondary mds-button--small">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--92460">
<input id="defensive--92460" value="defensive" class="mds-button__input" type="radio" name="html-small">
<span for="defensive--92460" class="mds-button mds-button--secondary mds-button--small">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--35473">
<input id="sensitive--35473" value="sensitive" class="mds-button__input" type="radio" name="html-small">
<span for="sensitive--35473" class="mds-button mds-button--secondary mds-button--small">
Sensitive
</span>
</label>
</div>
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="filter--94182">
<input id="filter--94182" value="filter" class="mds-button__input" type="radio" name="small-with-icon" checked>
<span for="filter--94182" class="mds-button mds-button--secondary mds-button--small">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#funnel--s">
</use>
</svg>
<span class="mds-button__text">
Filter
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="upload--24150">
<input id="upload--24150" value="upload" class="mds-button__input" type="radio" name="small-with-icon">
<span for="upload--24150" class="mds-button mds-button--secondary mds-button--small">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#upload--s">
</use>
</svg>
<span class="mds-button__text">
Upload
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="search--48896">
<input id="search--48896" value="search" class="mds-button__input" type="radio" name="small-with-icon">
<span for="search--48896" class="mds-button mds-button--secondary mds-button--small">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#search--s">
</use>
</svg>
<span class="mds-button__text">
Search
</span>
</span>
</label>
</div>
<div class="mds-button-group mds-button-group--icon-only">
<button class="mds-button mds-button--icon-only mds-button--small" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#search--s">
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only mds-button--small" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#heart--s">
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only mds-button--small" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#pencil--s">
</use>
</svg>
</button>
</div>
<mds-button-group>
<mds-button type="radio" variation="secondary" size="small" name="mdswc-small" value="cyclical" checked>Cyclical</mds-button>
<mds-button type="radio" variation="secondary" size="small" name="mdswc-small" value="defensive">Defensive</mds-button>
<mds-button type="radio" variation="secondary" size="small" name="mdswc-small" value="sensitive">Sensitive</mds-button>
</mds-button-group>
<mds-button-group>
<mds-button icon="funnel--s" type="radio" variation="secondary" size="small" name="mdswc-small-icon" value="filter" checked>Filter</mds-button>
<mds-button icon="upload--s" type="radio" variation="secondary" size="small" name="mdswc-small-icon" value="upload">Upload</mds-button>
<mds-button icon="search--s" type="radio" variation="secondary" size="small" name="mdswc-small-icon" value="search">Search</mds-button>
</mds-button-group>
<mds-button-group>
<mds-button variation="icon-only" icon="search--s" size="small" text="search"></mds-button>
<mds-button variation="icon-only" icon="heart--s" size="small" text="favorite"></mds-button>
<mds-button variation="icon-only" icon="pencil--s" size="small" text="edit"></mds-button>
</mds-button-group>
Icon size is predetermined and applied automatically. To avoid undesirable scaling of icon artwork, use the chart below to choose the correct icon size to use in your button group.
Type
|
Small
|
Medium
|
Large
|
---|---|---|---|
Default |
|||
Icon Only |
N/A |
Class
|
Applies to
|
Outcome
|
---|---|---|
|
|
Adding an |
|
|
Adding this modifier to the |
|
|
Adding this modifier to the |
|
|
Deprecated, will be removed in v3.0. Adding this modifier keeps all of the buttons the same height even when one of the buttons has wrapping text. Only use when text wrapping occurs within the button group. |
When setting props as attributes on a custom HTML element, use kebab-case
instead of camelCase
.
Prop
|
Type
|
Validation
|
Default
|
Description
|
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
Boolean |
— |
|
If |
Pass two or more <mds-button>
custom elements between the <mds-button-group></mds-button-group>
tags to set the items in the button group.
Using the default slot for content:
<mds-button-group>
<mds-button type="radio" variation="secondary" name="mustmatch" value="one" checked> Item One </mds-button>
<mds-button type="radio" variation="secondary" name="mustmatch" value="two"> Item Two </mds-button>
</mds-button-group>
box-shadow
property to create an outline. Internet Explorer and Safari have known issues rendering these outlines when using the browser’s zoom functionality. This visual defect doesn’t affect the functionality of the component.role="group"
attribute for a default button group.role="navigation"
.role="toolbar"
.aria-label="..."
to describe the intention of the button group.aria-label="View Toggle"
could describe a button group set that changes the view of a content module below the button group.