2.17.0
Button Groups join two or more buttons into a unified control, formerly called a segmented control.
Use to create a mutually exclusive toggle. Buttons within the group follow the same visual and behavioral conventions as the secondary Button.
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="cyclical--67050">
<input id="cyclical--67050" value="cyclical" class="mds-button__input" type="radio" name="html-1" checked>
<span for="cyclical--67050" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--70083">
<input id="defensive--70083" value="defensive" class="mds-button__input" type="radio" name="html-1">
<span for="defensive--70083" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--24522">
<input id="sensitive--24522" value="sensitive" class="mds-button__input" type="radio" name="html-1">
<span for="sensitive--24522" class="mds-button mds-button--secondary">
Sensitive
</span>
</label>
</div>
<mds-button-group>
<mds-button variation="secondary" type="radio" name="wc-1" value="cyclical" checked>Cyclical</mds-button>
<mds-button variation="secondary" type="radio" name="wc-1" value="defensive">Defensive</mds-button>
<mds-button variation="secondary" type="radio" name="wc-1" value="sensitive">Sensitive</mds-button>
</mds-button-group>
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="cyclical--99303">
<input id="cyclical--99303" value="cyclical" class="mds-button__input" type="radio" name="html-5" checked>
<span for="cyclical--99303" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--8846">
<input id="defensive--8846" value="defensive" class="mds-button__input" type="radio" name="html-5">
<span for="defensive--8846" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--53432">
<input id="sensitive--53432" value="sensitive" class="mds-button__input" type="radio" disabled name="html-5">
<span for="sensitive--53432" class="mds-button mds-button--secondary">
Sensitive
</span>
</label>
</div>
<mds-button-group>
<mds-button variation="secondary" type="radio" name="wc-5" value="cyclical" checked>Cyclical</mds-button>
<mds-button variation="secondary" type="radio" name="wc-5" value="defensive">Defensive</mds-button>
<mds-button variation="secondary" type="radio" name="wc-5" value="sensitive" disabled>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--69269">
<input id="cyclical--69269" value="cyclical" class="mds-button__input" type="radio" name="html-6" checked>
<span for="cyclical--69269" class="mds-button mds-button--secondary">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--81863">
<input id="defensive--81863" value="defensive" class="mds-button__input" type="radio" name="html-6">
<span for="defensive--81863" class="mds-button mds-button--secondary">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--22645">
<input id="sensitive--22645" value="sensitive" class="mds-button__input" type="radio" name="html-6">
<span for="sensitive--22645" class="mds-button mds-button--secondary">
Sensitive
</span>
</label>
</div>
<mds-button-group width="full">
<mds-button variation="secondary" type="radio" name="wc-6" value="cyclical" checked>Cyclical</mds-button>
<mds-button variation="secondary" type="radio" name="wc-6" value="defensive">Defensive</mds-button>
<mds-button variation="secondary" type="radio" name="wc-6" 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--77100">
<input id="filter--77100" value="filter" class="mds-button__input" type="radio" name="html-7" checked>
<span for="filter--77100" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#funnel--s">
</use>
</svg>
<span class="mds-button__text">
Filter
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="upload--22455">
<input id="upload--22455" value="upload" class="mds-button__input" type="radio" name="html-7">
<span for="upload--22455" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#upload--s">
</use>
</svg>
<span class="mds-button__text">
Upload
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="search--23567">
<input id="search--23567" value="search" class="mds-button__input" type="radio" name="html-7">
<span for="search--23567" class="mds-button mds-button--secondary">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#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="wc-7" value="filter" checked>Filter</mds-button>
<mds-button icon="upload--s" variation="secondary" type="radio" name="wc-7" value="upload">Upload</mds-button>
<mds-button icon="search--s" variation="secondary" type="radio" name="wc-7" value="search">Search</mds-button>
</mds-button-group>
Use to create toolbars.
<div class="mds-button-group mds-button-group--icon-only">
<button class="mds-button mds-button--icon-only" type="button" aria-label="Notifications">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#bell-padless">
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button" aria-label="Create New">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#create-padless">
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button" aria-label="Help">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#question-circle-padless">
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button" aria-label="My Acccount">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#person-padless">
</use>
</svg>
</button>
</div>
<mds-button-group>
<mds-button variation="icon-only" icon="bell-padless" text="Notifications"></mds-button>
<mds-button variation="icon-only" icon="create-padless" text="New"></mds-button>
<mds-button variation="icon-only" icon="question-circle-padless" text="Help"></mds-button>
<mds-button variation="icon-only" icon="person-padless" text="My Account"></mds-button>
</mds-button-group>
<div class="mds-button-group mds-button-group--icon-only">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#bell-padless">
<title>Notifications</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#create-padless">
<title>Create New</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only mds-button--disabled" type="button" disabled>
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#question-circle-padless">
<title>Help</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#person-padless">
<title>My Acccount</title>
</use>
</svg>
</button>
</div>
<mds-button-group>
<mds-button variation="icon-only" icon="bell-padless" text="Notifications"></mds-button>
<mds-button variation="icon-only" icon="create-padless" text="New"></mds-button>
<mds-button variation="icon-only" icon="question-circle-padless" text="Help" disabled></mds-button>
<mds-button variation="icon-only" icon="person-padless" text="My Account"></mds-button>
</mds-button-group>
<title>
within the svg tag to describe the intent of the button.$mds-space-inline-right-2-x
space, and vertically align middle the icon-only button group.<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="cyclical--28139">
<input id="cyclical--28139" value="cyclical" class="mds-button__input" type="radio" name="html-small" checked>
<span for="cyclical--28139" class="mds-button mds-button--secondary mds-button--small">
Cyclical
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="defensive--79199">
<input id="defensive--79199" value="defensive" class="mds-button__input" type="radio" name="html-small">
<span for="defensive--79199" class="mds-button mds-button--secondary mds-button--small">
Defensive
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="sensitive--18729">
<input id="sensitive--18729" value="sensitive" class="mds-button__input" type="radio" name="html-small">
<span for="sensitive--18729" class="mds-button mds-button--secondary mds-button--small">
Sensitive
</span>
</label>
</div>
<br><br>
<div class="mds-button-group">
<label class="mds-button__input-outer-wrapper" for="filter--4390">
<input id="filter--4390" value="filter" class="mds-button__input" type="radio" name="small-with-icon" checked>
<span for="filter--4390" 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="/icons/mds.svg#funnel--s">
</use>
</svg>
<span class="mds-button__text">
Filter
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="upload--30903">
<input id="upload--30903" value="upload" class="mds-button__input" type="radio" name="small-with-icon">
<span for="upload--30903" 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="/icons/mds.svg#upload--s">
</use>
</svg>
<span class="mds-button__text">
Upload
</span>
</span>
</label>
<label class="mds-button__input-outer-wrapper" for="search--38779">
<input id="search--38779" value="search" class="mds-button__input" type="radio" name="small-with-icon">
<span for="search--38779" 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="/icons/mds.svg#search--s">
</use>
</svg>
<span class="mds-button__text">
Search
</span>
</span>
</label>
</div>
<br><br>
<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="/icons/mds.svg#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="/icons/mds.svg#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="/icons/mds.svg#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>
<br><br>
<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>
<br><br>
<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. |
Prop
|
Type
|
Validation
|
Default
|
Description
|
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
String |
— |
— |
The |
|
String |
One of: |
|
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.