Skip to content

Commit 1c60acf

Browse files
crisbetovivian-hu-zz
authored andcommitted
docs(button-toggle): add appearance docs and example (#13416)
As discussed in #12443, these changes add some docs and a live example for the button toggle `appearance`.
1 parent 900c1f7 commit 1c60acf

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

src/lib/button-toggle/button-toggle.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
`<mat-button-toggle>` are on/off toggles with the appearance of a button. These toggles can be
2-
configured to behave as either radio-buttons or checkboxes. While they can be standalone, they are
1+
`<mat-button-toggle>` are on/off toggles with the appearance of a button. These toggles can be
2+
configured to behave as either radio-buttons or checkboxes. While they can be standalone, they are
33
typically part of a `mat-button-toggle-group`.
44

55

66
<!-- example(button-toggle-overview) -->
77

88
### Exclusive selection vs. multiple selection
99
By default, `mat-button-toggle-group` acts like a radio-button group- only one item can be selected.
10-
In this mode, the `value` of the `mat-button-toggle-group` will reflect the value of the selected
11-
button and `ngModel` is supported.
10+
In this mode, the `value` of the `mat-button-toggle-group` will reflect the value of the selected
11+
button and `ngModel` is supported.
1212

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

17+
### Appearance
18+
By default, the appearance of `mat-button-toggle-group` and `mat-button-toggle` will follow the
19+
latest Material Design guidelines. If you want to, you can switch back to the appearance that was
20+
following the previous Material Design spec by using the `appearance` input. The `appearance` can
21+
be configured globally using the `MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS` injection token.
22+
23+
<!-- example(button-toggle-appearance) -->
24+
1725
### Accessibility
1826
The button-toggles will present themselves as either checkboxes or radio-buttons based on the
19-
presence of the `multiple` attribute.
27+
presence of the `multiple` attribute.
2028

2129
For button toggles containing only icons, each button toggle should be given a meaningful label via
2230
`aria-label` or `aria-labelledby`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<p>
2+
Default appearance:
3+
<mat-button-toggle-group name="fontStyle" aria-label="Font Style">
4+
<mat-button-toggle value="bold">Bold</mat-button-toggle>
5+
<mat-button-toggle value="italic">Italic</mat-button-toggle>
6+
<mat-button-toggle value="underline">Underline</mat-button-toggle>
7+
</mat-button-toggle-group>
8+
</p>
9+
10+
<p>
11+
Legacy appearance:
12+
<mat-button-toggle-group appearance="legacy" name="fontStyle" aria-label="Font Style">
13+
<mat-button-toggle value="bold">Bold</mat-button-toggle>
14+
<mat-button-toggle value="italic">Italic</mat-button-toggle>
15+
<mat-button-toggle value="underline">Underline</mat-button-toggle>
16+
</mat-button-toggle-group>
17+
</p>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
/**
4+
* @title Button toggle appearance
5+
*/
6+
@Component({
7+
selector: 'button-toggle-appearance-example',
8+
templateUrl: 'button-toggle-appearance-example.html',
9+
styleUrls: ['button-toggle-appearance-example.css'],
10+
})
11+
export class ButtonToggleAppearanceExample {}

0 commit comments

Comments
 (0)