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--35838">
<input id="cyclical--35838" value="cyclical" class="mds-button__input" type="radio" name="default-html" checked>
<span for="cyclical--35838" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--21267">
<input id="defensive--21267" value="defensive" class="mds-button__input" type="radio" name="default-html">
<span for="defensive--21267" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--47915">
<input id="sensitive--47915" value="sensitive" class="mds-button__input" type="radio" name="default-html">
<span for="sensitive--47915" 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--49334">
<input id="cyclical--49334" value="cyclical" class="mds-button__input" type="radio" name="full-width-html" checked>
<span for="cyclical--49334" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--85840">
<input id="defensive--85840" value="defensive" class="mds-button__input" type="radio" name="full-width-html">
<span for="defensive--85840" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--32381">
<input id="sensitive--32381" value="sensitive" class="mds-button__input" type="radio" name="full-width-html">
<span for="sensitive--32381" 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--91554">
<input id="filter--91554" value="filter" class="mds-button__input" type="radio" name="with-icons-html" checked>
<span for="filter--91554" 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--68003">
<input id="upload--68003" value="upload" class="mds-button__input" type="radio" name="with-icons-html">
<span for="upload--68003" 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--2235">
<input id="search--2235" value="search" class="mds-button__input" type="radio" name="with-icons-html">
<span for="search--2235" 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--72274">
<input id="cyclical--72274" value="cyclical" class="mds-button__input" type="radio" name="html-small" checked>
<span for="cyclical--72274" class="mds-button mds-button--secondary mds-button--small">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--32800">
<input id="defensive--32800" value="defensive" class="mds-button__input" type="radio" name="html-small">
<span for="defensive--32800" class="mds-button mds-button--secondary mds-button--small">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--66057">
<input id="sensitive--66057" value="sensitive" class="mds-button__input" type="radio" name="html-small">
<span for="sensitive--66057" 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--91225">
<input id="filter--91225" value="filter" class="mds-button__input" type="radio" name="small-with-icon" checked>
<span for="filter--91225" 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--48319">
<input id="upload--48319" value="upload" class="mds-button__input" type="radio" name="small-with-icon">
<span for="upload--48319" 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--21268">
<input id="search--21268" value="search" class="mds-button__input" type="radio" name="small-with-icon">
<span for="search--21268" 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.