Skip to content

Commit 5fa8f67

Browse files
authored
docs(material/button): update button documentation and examples for M3 (angular#29252)
1 parent 008212a commit 5fa8f67

File tree

7 files changed

+40
-210
lines changed

7 files changed

+40
-210
lines changed

src/components-examples/material/button/button-overview/button-overview-example.html

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
<div class="example-label">Basic</div>
33
<div class="example-button-row">
44
<button mat-button>Basic</button>
5-
<button mat-button color="primary">Primary</button>
6-
<button mat-button color="accent">Accent</button>
7-
<button mat-button color="warn">Warn</button>
85
<button mat-button disabled>Disabled</button>
96
<a mat-button href="https://www.google.com/" target="_blank">Link</a>
107
</div>
@@ -14,9 +11,6 @@
1411
<div class="example-label">Raised</div>
1512
<div class="example-button-row">
1613
<button mat-raised-button>Basic</button>
17-
<button mat-raised-button color="primary">Primary</button>
18-
<button mat-raised-button color="accent">Accent</button>
19-
<button mat-raised-button color="warn">Warn</button>
2014
<button mat-raised-button disabled>Disabled</button>
2115
<a mat-raised-button href="https://www.google.com/" target="_blank">Link</a>
2216
</div>
@@ -26,9 +20,6 @@
2620
<div class="example-label">Stroked</div>
2721
<div class="example-button-row">
2822
<button mat-stroked-button>Basic</button>
29-
<button mat-stroked-button color="primary">Primary</button>
30-
<button mat-stroked-button color="accent">Accent</button>
31-
<button mat-stroked-button color="warn">Warn</button>
3223
<button mat-stroked-button disabled>Disabled</button>
3324
<a mat-stroked-button href="https://www.google.com/" target="_blank">Link</a>
3425
</div>
@@ -38,9 +29,6 @@
3829
<div class="example-label">Flat</div>
3930
<div class="example-button-row">
4031
<button mat-flat-button>Basic</button>
41-
<button mat-flat-button color="primary">Primary</button>
42-
<button mat-flat-button color="accent">Accent</button>
43-
<button mat-flat-button color="warn">Warn</button>
4432
<button mat-flat-button disabled>Disabled</button>
4533
<a mat-flat-button href="https://www.google.com/" target="_blank">Link</a>
4634
</div>
@@ -53,15 +41,6 @@
5341
<button mat-icon-button aria-label="Example icon button with a vertical three dot icon">
5442
<mat-icon>more_vert</mat-icon>
5543
</button>
56-
<button mat-icon-button color="primary" aria-label="Example icon button with a home icon">
57-
<mat-icon>home</mat-icon>
58-
</button>
59-
<button mat-icon-button color="accent" aria-label="Example icon button with a menu icon">
60-
<mat-icon>menu</mat-icon>
61-
</button>
62-
<button mat-icon-button color="warn" aria-label="Example icon button with a heart icon">
63-
<mat-icon>favorite</mat-icon>
64-
</button>
6544
<button mat-icon-button disabled aria-label="Example icon button with a open in new tab icon">
6645
<mat-icon>open_in_new</mat-icon>
6746
</button>
@@ -74,20 +53,10 @@
7453
<div class="example-button-row">
7554
<div class="example-flex-container">
7655
<div class="example-button-container">
77-
<button mat-fab color="primary" aria-label="Example icon button with a delete icon">
56+
<button mat-fab aria-label="Example icon button with a delete icon">
7857
<mat-icon>delete</mat-icon>
7958
</button>
8059
</div>
81-
<div class="example-button-container">
82-
<button mat-fab color="accent" aria-label="Example icon button with a bookmark icon">
83-
<mat-icon>bookmark</mat-icon>
84-
</button>
85-
</div>
86-
<div class="example-button-container">
87-
<button mat-fab color="warn" aria-label="Example icon button with a home icon">
88-
<mat-icon>home</mat-icon>
89-
</button>
90-
</div>
9160
<div class="example-button-container">
9261
<button mat-fab disabled aria-label="Example icon button with a heart icon">
9362
<mat-icon>favorite</mat-icon>
@@ -102,25 +71,40 @@
10271
<div class="example-button-row">
10372
<div class="example-flex-container">
10473
<div class="example-button-container">
105-
<button mat-mini-fab color="primary" aria-label="Example icon button with a menu icon">
74+
<button mat-mini-fab aria-label="Example icon button with a menu icon">
10675
<mat-icon>menu</mat-icon>
10776
</button>
10877
</div>
10978
<div class="example-button-container">
110-
<button mat-mini-fab color="accent" aria-label="Example icon button with a plus one icon">
111-
<mat-icon>plus_one</mat-icon>
79+
<button mat-mini-fab disabled aria-label="Example icon button with a home icon">
80+
<mat-icon>home</mat-icon>
11281
</button>
11382
</div>
83+
</div>
84+
</div>
85+
</section>
86+
<section>
87+
<div class="example-label">Extended Fab</div>
88+
<div class="example-button-row">
89+
<div class="example-flex-container">
11490
<div class="example-button-container">
115-
<button mat-mini-fab color="warn" aria-label="Example icon button with a filter list icon">
116-
<mat-icon>filter_list</mat-icon>
91+
<button mat-fab extended>
92+
<mat-icon>favorite</mat-icon>
93+
Basic
11794
</button>
11895
</div>
11996
<div class="example-button-container">
120-
<button mat-mini-fab disabled aria-label="Example icon button with a home icon">
121-
<mat-icon>home</mat-icon>
97+
<button mat-fab extended disabled>
98+
<mat-icon>favorite</mat-icon>
99+
Disabled
122100
</button>
123101
</div>
102+
<div class="example-button-container">
103+
<a mat-fab extended routerLink=".">
104+
<mat-icon>favorite</mat-icon>
105+
Link
106+
</a>
107+
</div>
124108
</div>
125109
</div>
126110
</section>

src/components-examples/material/button/button-types/button-types-example.css

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/components-examples/material/button/button-types/button-types-example.html

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/components-examples/material/button/button-types/button-types-example.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export {ButtonOverviewExample} from './button-overview/button-overview-example';
2-
export {ButtonTypesExample} from './button-types/button-types-example';
32
export {ButtonDisabledInteractiveExample} from './button-disabled-interactive/button-disabled-interactive-example';
43
export {ButtonHarnessExample} from './button-harness/button-harness-example';

src/material/button/button-base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ export class MatButtonBase implements AfterViewInit, OnDestroy {
107107
this._rippleLoader?.attachRipple(this._elementRef.nativeElement, v);
108108
}
109109

110-
/** Theme color palette of the button */
110+
/**
111+
* Theme color palette of the button. This API is supported in M2 themes
112+
* only, it has no effect in M3 themes.
113+
*
114+
* For information on applying color variants in M3, see
115+
* https://material.angular.io/guide/theming#using-component-color-variants
116+
*/
111117
@Input() color?: string | null;
112118

113119
/** Whether the ripple effect is disabled or not. */

src/material/button/button.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,15 @@ There are several button variants, each applied as an attribute:
1212

1313
| Attribute | Description |
1414
|----------------------|--------------------------------------------------------------------------|
15-
| `mat-button` | Rectangular text button w/ no elevation |
16-
| `mat-raised-button` | Rectangular contained button w/ elevation |
17-
| `mat-flat-button` | Rectangular contained button w/ no elevation |
18-
| `mat-stroked-button` | Rectangular outlined button w/ no elevation |
15+
| `mat-button` | Rectangular text button w/ no elevation and rounded corners |
16+
| `mat-raised-button` | Rectangular contained button w/ elevation and rounded corners |
17+
| `mat-flat-button` | Rectangular contained button w/ no elevation and rounded corners |
18+
| `mat-stroked-button` | Rectangular outlined button w/ no elevation and rounded corners |
1919
| `mat-icon-button` | Circular button with a transparent background, meant to contain an icon |
20-
| `mat-fab` | Circular button w/ elevation, defaults to theme's accent color |
20+
| `mat-fab` | Square button w/ elevation and rounded corners, meant to contain an icon. Can be [extended](https://material.angular.io/components/button/overview#extended-fab-buttons) to a rectangle to also fit a label |
2121
| `mat-mini-fab` | Same as `mat-fab` but smaller |
2222

2323

24-
### Theming
25-
Buttons can be colored in terms of the current theme using the `color` property to set the
26-
background color to `primary`, `accent`, or `warn`.
27-
28-
### Capitalization
29-
According to the Material design spec button text has to be capitalized, however we have opted not
30-
to capitalize buttons automatically via `text-transform: uppercase`, because it can cause issues in
31-
certain locales. It is also worth noting that using ALL CAPS in the text itself causes issues for
32-
screen-readers, which will read the text character-by-character. We leave the decision of how to
33-
approach this to the consuming app.
34-
3524
### Extended fab buttons
3625
Traditional fab buttons are circular and only have space for a single icon. However, you can add the
3726
`extended` attribute to allow the fab to expand into a rounded rectangle shape with space for a text
@@ -64,6 +53,11 @@ default. A `<button>` element should be used for any interaction that _performs
6453
current page_. An `<a>` element should be used for any interaction that _navigates to another
6554
URL_. All standard accessibility best practices for buttons and anchors apply to `MatButton`.
6655

56+
#### Capitalization
57+
Using ALL CAPS in the button text itself causes issues for screen-readers, which
58+
will read the text character-by-character. It can also cause issues for localization.
59+
We recommend not changing the default capitalization for the button text.
60+
6761
#### Disabling anchors
6862
`MatAnchor` supports disabling an anchor in addition to the features provided by the native
6963
`<a>` element. When you disable an anchor, the component sets `aria-disabled="true"` and

0 commit comments

Comments
 (0)