|
| 1 | +# md-button |
| 2 | + |
| 3 | +`md-button` is an HTML `<button>` or `<a>` tag enhanced with styling and animation to match the [spec of a Material Design button](https://www.google.com/design/spec/components/buttons.html). |
| 4 | + |
| 5 | +### Button types |
| 6 | + |
| 7 | +There are four types of buttons: |
| 8 | + 1. Flat buttons - `md-button` |
| 9 | + * Rectangular button |
| 10 | + * Defaults to white background |
| 11 | + * No box shadow |
| 12 | + 2. Raised buttons - `md-raised-button` |
| 13 | + * Rectangular button |
| 14 | + * Defaults to white background |
| 15 | + * Box shadow applied |
| 16 | + 3. Floating Action Buttons (FABs) - `md-fab` |
| 17 | + * Circular button |
| 18 | + * Defaults background to "accent" palette defined in theme |
| 19 | + * Box shadow applied |
| 20 | + * 56 by 56 px |
| 21 | + 4. Mini Floating Action Buttons (Mini FABs) - `md-mini-fab` |
| 22 | + * Circular button |
| 23 | + * Defaults background to "accent" palette defined in theme |
| 24 | + * Box shadow applied |
| 25 | + * 40 by 40 px |
| 26 | + |
| 27 | +Each is an attribute directive that you can add to a `button` or `a` tag. You can provide custom content to the button by inserting it |
| 28 | +between the tags, as you would with a normal button. |
| 29 | + |
| 30 | +Example: |
| 31 | + |
| 32 | + ```html |
| 33 | +<button md-button>FLAT</button> |
| 34 | +<button md-raised-button>RAISED</button> |
| 35 | +<button md-fab> |
| 36 | + <i class="material-icons md-24">add</i> |
| 37 | +</button> |
| 38 | +<button md-mini-fab> |
| 39 | + <i class="material-icons md-24">add</i> |
| 40 | +</button> |
| 41 | + ``` |
| 42 | + |
| 43 | +Output: |
| 44 | + |
| 45 | +<img src="https://material.angularjs.org/material2_assets/buttons/basic-buttons.png"> |
| 46 | + |
| 47 | +### Theming |
| 48 | + |
| 49 | +All button types can be themed to match your "primary" palette, your "accent" palette, or your "warn" palette using the `color` attribute. |
| 50 | +Simply pass in the palette name. |
| 51 | + |
| 52 | +In flat buttons, the palette chosen will affect the text color, while in other buttons, it affects the background. |
| 53 | + |
| 54 | +Example: |
| 55 | + |
| 56 | + ```html |
| 57 | +<button md-raised-button color="primary">PRIMARY</button> |
| 58 | +<button md-raised-button color="accent">ACCENT</button> |
| 59 | +<button md-raised-button color="warn">WARN</button> |
| 60 | + ``` |
| 61 | + |
| 62 | +Output: |
| 63 | + |
| 64 | +<img src="https://material.angularjs.org/material2_assets/buttons/colored-buttons.png"> |
| 65 | + |
| 66 | +### Disabling |
| 67 | + |
| 68 | +You can disable any button type through the native `disabled` property. You can add it directly, or bind it to a property on your |
| 69 | +component class. |
| 70 | + |
| 71 | +```html |
| 72 | +<button md-button disabled>off</button> |
| 73 | +<button md-raised-button [disabled]="isDisabled">off</button> |
| 74 | +<button md-mini-fab [disabled]="isDisabled">check circle</button> |
| 75 | +``` |
| 76 | + |
| 77 | +Output: |
| 78 | + |
| 79 | +<img src="https://material.angularjs.org/material2_assets/buttons/disabled-buttons.png"> |
| 80 | + |
| 81 | +### Accessibility |
| 82 | + |
| 83 | + * In high contrast mode, a strong border is added to the button to make it easier to see. |
| 84 | + * Button focus events originating from the keyboard will retain focus styles, while button focus events from the mouse will not. |
| 85 | + * As `md-button` is added to an existing `button` or `a` tag, it enjoys all the accessibility natively built into these elements. |
| 86 | + |
| 87 | + |
| 88 | +### Upcoming work |
| 89 | + |
| 90 | +We will also be adding ink ripples to buttons in an upcoming milestone. |
| 91 | + |
| 92 | +### API Summary |
| 93 | + |
| 94 | +Properties: |
| 95 | + |
| 96 | +| Name | Type | Description | |
| 97 | +| --- | --- | --- | |
| 98 | +| `color` | `"primary"|"accent"|"warn"` | The color palette of the button |
| 99 | +| `disabled` | boolean | Whether or not the button is disabled |
0 commit comments