2023-06-03 02:32:02 +03:00
<!-- catalog - only - start --> <!-- - - -
name: Icon Buttons
dirname: iconbutton
-----><!-- catalog - only - end -->
< catalog-component-header >
< catalog-component-header-title slot = "title" >
# Icon Buttons
2023-04-05 19:43:29 +03:00
<!-- *
# Document freshness: For more information, see go/fresh-source.
freshness: { owner: 'dfreedm' reviewed: '2023-04-03' }
2023-04-27 01:09:51 +03:00
tag: 'docType:reference'
2023-04-05 19:43:29 +03:00
*-->
<!-- go/md - icon - button -->
<!-- [TOC] -->
2023-07-28 01:54:09 +03:00
<!-- external - only - start -->
2023-07-27 21:45:21 +03:00
**This documentation is fully rendered on the
2023-07-28 01:54:09 +03:00
[Material Web catalog ](https://material-web.dev/components/icon-button/ ).**
<!-- external - only - end -->
2023-07-27 21:45:21 +03:00
2023-04-05 19:43:29 +03:00
[Icon buttons ](https://m3.material.io/components/icon-buttons )<!-- {.external} --> help
people take supplementary actions with a single tap.
2023-06-03 02:32:02 +03:00
< / catalog-component-header-title >
< img
class="hero"
alt="The top half of a phone application with a back icon button at the top left and three icon buttons on the top right, heart, share, and three dot."
src="images/iconbutton/hero.png">
2023-04-05 19:43:29 +03:00
2023-06-03 02:32:02 +03:00
< / catalog-component-header >
2023-04-05 19:43:29 +03:00
* [Design article ](https://m3.material.io/components/icon-buttons ) <!-- {.external} -->
* API Documentation (*coming soon*)
2023-04-25 00:05:46 +03:00
* [Source code ](https://github.com/material-components/material-web/tree/main/iconbutton )
2023-04-05 19:43:29 +03:00
<!-- {.external} -->
2023-06-03 02:32:02 +03:00
<!-- catalog - only - start -->
<!--
## Interactive Demo
{% playgroundexample dirname=dirname, previewHeight=700 %}
-->
<!-- catalog - only - end -->
2023-04-05 19:43:29 +03:00
## Types
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
![Side by side view of standard and contained icon buttons ](images/iconbutton/buttons.png "1 - Standard Icon Button. 2 - Contained Icon Button (including filled, filled tonal, and outlined styles )")
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/buttons.html" -->
2023-06-03 02:32:02 +03:00
2023-07-31 21:37:24 +03:00
1. [Icon Button ](#icon-button )
2023-06-03 02:32:02 +03:00
2. [Filled Icon Button ](#filled-icon-button )
3. [Filled Tonal Icon Button ](#filled-tonal-icon-button )
4. [Outlined Icon Button ](#outlined-icon-button )
2023-04-05 19:43:29 +03:00
## Usage
Use icon buttons to display actions in a compact layout. Icon buttons can
represent opening actions such as opening an overflow menu or search, or
represent binary actions that can be toggled on and off, such as favorite or
bookmark.
Icon buttons can be grouped together or they can stand alone.
To use icons by name, see the [Icon ](icon.md#usage ) documentation for loading
the icon font.
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![A row of icon buttons ](images/iconbutton/usage.png "Icon buttons can be used within other components, such as a bottom app bar" )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
2023-07-31 21:37:24 +03:00
< md-icon-button >
2023-06-03 02:32:02 +03:00
< md-icon > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-06-03 02:32:02 +03:00
< md-filled-icon-button >
< md-icon > check< / md-icon >
< / md-filled-icon-button >
< md-filled-tonal-icon-button >
< md-icon > check< / md-icon >
< / md-filled-tonal-icon-button >
< md-outlined-icon-button >
< md-icon > check< / md-icon >
< / md-outlined-icon-button >
2023-04-05 19:43:29 +03:00
```
### Links
Add an
[`href` ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href )<!-- {.external} -->
and optionally a
[`target` ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target )<!-- {.external} -->
attribute to turn the icon button into a link.
```html
2023-07-31 21:37:24 +03:00
< md-icon-button href = "https://google.com" >
2023-05-09 21:55:38 +03:00
< md-icon > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
```
### Toggle
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![Two rows of toggling icon buttons, the top row is unselected and the bottom
row is
selected](images/iconbutton/usage-toggle.png "Unselected and Selected Icon Button")
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage - toggle.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
Toggle icon buttons allow a single choice to be selected or deselected, such as
adding or removing something from favorites.
```html
< div >
2023-07-31 21:37:24 +03:00
< md-icon-button toggle >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
< md-filled-icon-button toggle >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-filled-icon-button >
< md-filled-tonal-icon-button toggle >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-filled-tonal-icon-button >
< md-outlined-icon-button toggle >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-outlined-icon-button >
< / div >
< div >
2023-07-31 21:37:24 +03:00
< md-icon-button toggle selected >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
< md-filled-icon-button toggle selected >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-filled-icon-button >
< md-filled-tonal-icon-button toggle selected >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-filled-tonal-icon-button >
< md-outlined-icon-button toggle selected >
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-04-05 19:43:29 +03:00
< / md-outlined-icon-button >
< / div >
```
## Accessibility
Add an
[`aria-label` ](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label )<!-- {.external} -->
attribute to buttons whose labels need a more descriptive label.
```html
2023-07-31 21:37:24 +03:00
< md-icon-button aria-label = "Search for Contact" >
2023-05-09 21:55:38 +03:00
< md-icon > search< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
```
### Toggle
2023-08-17 21:36:30 +03:00
Add a `aria-label-selected` attribute to toggle buttons whose labels need a more
2023-04-05 19:43:29 +03:00
descriptive label when selected.
```html
2023-07-31 21:37:24 +03:00
< md-icon-button toggle
2023-04-05 19:43:29 +03:00
aria-label="Unselected"
2023-08-17 21:36:30 +03:00
aria-label-selected="Selected">
2023-05-09 21:55:38 +03:00
< md-icon > close< / md-icon >
2023-08-31 23:14:06 +03:00
< md-icon slot = "selected" > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
```
2023-07-31 21:37:24 +03:00
## Icon Button
2023-04-05 19:43:29 +03:00
Use
[icon buttons ](https://m3.material.io/components/icon-buttons/guidelines )<!-- {.external} -->
to display actions in a compact layout. Icon buttons can represent opening
actions such as opening an overflow menu or search, or represent binary actions
that can be toggled on and off, such as favorite or bookmark.
Icon buttons can be grouped together or they can stand alone.
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![A check icon ](images/iconbutton/usage-standard.png "Standard Icon Button with Check icon" )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage - standard.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
2023-07-31 21:37:24 +03:00
< md-icon-button >
2023-05-09 21:55:38 +03:00
< md-icon > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
```
## Filled Icon Button
<!-- go/md - filled - icon - button -->
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![A circular button with a check icon ](images/iconbutton/usage-filled.png "Filled Icon Button" )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage - filled.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
Filled icon buttons have higher visual impact and are best for high emphasis
actions.
```html
2023-05-09 21:55:38 +03:00
< md-filled-icon-button >
< md-icon > check< / md-icon >
< / md-filled-icon-button >
2023-04-05 19:43:29 +03:00
```
## Filled Tonal Icon Button
<!-- go/md - filled - tonal - icon - button -->
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![A filled tonal icon button with a check icon ](images/iconbutton/usage-filled-tonal.png "Filled Tonal Icon Button" )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage - filled - tonal.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
Filled tonal icon buttons are a middle ground between filled and outlined icon
buttons. They're useful in contexts where the button requires slightly more
emphasis than an outline would give, such as a secondary action paired with a
high emphasis action.
```html
2023-05-09 21:55:38 +03:00
< md-filled-tonal-icon-button >
< md-icon > check< / md-icon >
< / md-filled-tonal-icon-button >
2023-04-05 19:43:29 +03:00
```
## Outlined Icon Button
<!-- go/md - outlined - icon - button -->
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![An outlined circular icon button with a check icon ](images/iconbutton/usage-outlined.png "Outlined Icon button" )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/usage - outlined.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
Outlined icon buttons are medium-emphasis buttons. They're useful when an icon
button needs more emphasis than a standard icon button but less than a filled or
filled tonal icon button.
```html
2023-05-09 21:55:38 +03:00
< md-outlined-icon-button >
< md-icon > check< / md-icon >
< / md-outlined-icon-button >
2023-04-05 19:43:29 +03:00
```
## Theming
2023-09-11 19:32:19 +03:00
Icon Button supports [Material theming ](../theming/README.md ) and can be
customized in terms of color, and shape.
2023-04-05 19:43:29 +03:00
2023-07-31 21:37:24 +03:00
### Icon Button tokens
2023-04-05 19:43:29 +03:00
2023-08-01 20:01:26 +03:00
Token | Default value
------------------------------------ | -----------------------------------
`--md-icon-button-icon-color` | `--md-sys-color-on-surface-variant`
`--md-icon-button-state-layer-shape` | `9999px`
`--md-icon-button-icon-size` | `24px`
2023-04-05 19:43:29 +03:00
2023-06-26 23:37:43 +03:00
* [All tokens ](https://github.com/material-components/material-web/blob/main/tokens/_md-comp-icon-button.scss )
2023-04-05 19:43:29 +03:00
<!-- {.external} -->
2023-07-31 21:37:24 +03:00
### Icon Button example
2023-04-05 19:43:29 +03:00
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![Image of a standard icon button with a different theme applied ](images/iconbutton/theming-standard.png "Standard icon button theming example." )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/theming - standard.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
< style >
:root {
--md-icon-button-icon-size: 32px;
--md-sys-color-on-surface-variant: #dc362e ;
2023-06-03 02:32:02 +03:00
background-color: #fff8f6 ;
2023-04-05 19:43:29 +03:00
}
< / style >
2023-07-31 21:37:24 +03:00
< md-icon-button >
2023-05-09 21:55:38 +03:00
< md-icon > check< / md-icon >
2023-07-31 21:37:24 +03:00
< / md-icon-button >
2023-04-05 19:43:29 +03:00
```
### Filled Icon Button tokens
Token | Default value
-------------------------------------------------- | ------------------------
`--md-filled-icon-button-selected-container-color` | `--md-sys-color-primary`
`--md-filled-icon-button-container-shape` | `9999px`
`--md-filled-icon-button-container-size` | `40px`
`--md-filled-icon-button-icon-size` | `24px`
2023-06-26 23:37:43 +03:00
* [All tokens ](https://github.com/material-components/material-web/blob/main/tokens/_md-comp-filled-icon-button.scss )
2023-04-05 19:43:29 +03:00
<!-- {.external} -->
### Filled Icon Button example
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![Image of a filled icon button with a different theme applied ](images/iconbutton/theming-filled.png "Filled icon button theming example." )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/theming - filled.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
< style >
:root {
--md-filled-icon-button-container-size: 80px;
--md-filled-icon-button-icon-size: 40px;
--md-filled-icon-button-container-shape: 0px;
--md-sys-color-primary: #dc362e ;
2023-06-03 02:32:02 +03:00
background-color: #fff8f6 ;
2023-04-05 19:43:29 +03:00
}
< / style >
2023-05-09 21:55:38 +03:00
< md-filled-icon-button >
< md-icon > check< / md-icon >
< / md-filled-icon-button >
2023-04-05 19:43:29 +03:00
```
### Filled Tonal Icon Button tokens
Token | Default value
-------------------------------------------------------- | -------------
`--md-filled-tonal-icon-button-selected-container-color` | `--md-sys-color-secondary-container`
`--md-filled-tonal-icon-button-container-shape` | `9999px`
`--md-filled-tonal-icon-button-container-size` | `40px`
`--md-filled-tonal-icon-button-icon-size` | `24px`
### Filled Tonal Icon Button example
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![Image of a filled tonal icon button with a different theme applied ](images/iconbutton/theming-filled-tonal.png "Filled tonal icon button theming example." )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/theming - filled - tonal.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
< style >
:root {
--md-filled-tonal-icon-button-container-size: 80px;
--md-filled-tonal-icon-button-container-shape: 0px;
--md-filled-tonal-icon-button-icon-size: 40px;
--md-sys-color-secondary-container: #006A6A ;
}
< / style >
2023-05-09 21:55:38 +03:00
< md-filled-tonal-icon-button >
< md-icon > check< / md-icon >
< / md-filled-tonal-icon-button >
2023-04-05 19:43:29 +03:00
```
### Outlined Icon Button tokens
2023-08-01 20:01:26 +03:00
Token | Default value
------------------------------------------- | ------------------------
`--md-outlined-icon-button-outline-color` | `--md-sys-color-outline`
`--md-outlined-icon-button-outline-width` | `1px`
`--md-outlined-icon-button-container-shape` | `9999px`
`--md-outlined-icon-button-container-size` | `40px`
`--md-outlined-icon-button-icon-size` | `24px`
2023-04-05 19:43:29 +03:00
### Outlined Icon Button example
2023-07-28 01:54:09 +03:00
<!-- no - catalog - start -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
![Image of an outlined icon button with a different theme applied ](images/iconbutton/theming-outlined.png "Outlined icon button theming example." )
2023-07-28 01:54:09 +03:00
<!-- no - catalog - end -->
2023-06-24 01:09:04 +03:00
<!-- catalog - include "figures/iconbutton/theming - outlined.html" -->
2023-06-03 02:32:02 +03:00
2023-04-05 19:43:29 +03:00
```html
< style >
:root {
--md-outlined-icon-button-container-size: 80px;
--md-outlined-icon-button-container-shape: 0px;
--md-outlined-icon-button-icon-size: 40px;
2023-08-01 20:01:26 +03:00
--md-outlined-icon-button-outline-width: 4px;
2023-04-05 19:43:29 +03:00
--md-sys-color-outline: #006A6A ;
}
< / style >
2023-05-09 21:55:38 +03:00
< md-outlined-icon-button >
< md-icon > check< / md-icon >
< / md-outlined-icon-button >
2023-04-05 19:43:29 +03:00
```