Skip to content

docs(material/button-toggle): add selection mode example #23415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h3>Single selection</h3>
<mat-button-toggle-group name="favoriteColor" aria-label="Favorite Color">
<mat-button-toggle value="red">Red</mat-button-toggle>
<mat-button-toggle value="green">Green</mat-button-toggle>
<mat-button-toggle value="blue">Blue</mat-button-toggle>
</mat-button-toggle-group>

<h3>Multiple selection</h3>
<mat-button-toggle-group name="ingredients" aria-label="Ingredients" multiple>
<mat-button-toggle value="flour">Flour</mat-button-toggle>
<mat-button-toggle value="eggs">Eggs</mat-button-toggle>
<mat-button-toggle value="sugar">Sugar</mat-button-toggle>
</mat-button-toggle-group>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Component} from '@angular/core';

/**
* @title Button toggle selection mode
*/
@Component({
selector: 'button-toggle-mode-example',
templateUrl: 'button-toggle-mode-example.html',
})
export class ButtonToggleModeExample {}
3 changes: 3 additions & 0 deletions src/components-examples/material/button-toggle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import {
import {ButtonToggleOverviewExample} from './button-toggle-overview/button-toggle-overview-example';
import {ButtonToggleHarnessExample} from './button-toggle-harness/button-toggle-harness-example';
import {ButtonToggleFormsExample} from './button-toggle-forms/button-toggle-forms-example';
import {ButtonToggleModeExample} from './button-toggle-mode/button-toggle-mode-example';

export {
ButtonToggleAppearanceExample,
ButtonToggleExclusiveExample,
ButtonToggleOverviewExample,
ButtonToggleHarnessExample,
ButtonToggleFormsExample,
ButtonToggleModeExample,
};

const EXAMPLES = [
Expand All @@ -26,6 +28,7 @@ const EXAMPLES = [
ButtonToggleOverviewExample,
ButtonToggleHarnessExample,
ButtonToggleFormsExample,
ButtonToggleModeExample,
];

@NgModule({
Expand Down
4 changes: 3 additions & 1 deletion src/material/button-toggle/button-toggle.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ In this mode, the `value` of the `mat-button-toggle-group` will reflect the valu
button and `ngModel` is supported.

Adding the `multiple` attribute allows multiple items to be selected (checkbox behavior). In this
mode the values of the toggles are not used, the `mat-button-toggle-group` does not have a value,
mode the values of the toggles are not used, the `mat-button-toggle-group` does not have a value,
and `ngModel` is not supported.

<!-- example(button-toggle-mode) -->

### Appearance
By default, the appearance of `mat-button-toggle-group` and `mat-button-toggle` will follow the
latest Material Design guidelines. If you want to, you can switch back to the appearance that was
Expand Down