material-web/packages/icon-button
2019-08-15 14:51:43 -07:00
..
images Split icon button toggling into its own component 2019-08-15 11:35:22 -07:00
src Extends ESLint from @typescript-eslint (#371) 2019-08-15 14:51:43 -07:00
.npmignore Add an .npmignore to every package. 2019-08-13 10:24:31 -07:00
package.json chore: add repository.directory in package.json for all packages 2019-07-17 00:54:39 +03:00
README.md Split icon button toggling into its own component 2019-08-15 11:35:22 -07:00
tsconfig.json Update dependencies 2019-04-04 15:36:55 -07:00

<mwc-icon-button> Published on npm

IMPORTANT: The Material Web Components are a work in progress and subject to major changes until 1.0 release.

Icon buttons allow users to take actions, and make choices, with a single tap.

For the toggling version of this component, see <mwc-icon-button-toggle>

Material Design Guidelines: Button

Installation

npm install @material/mwc-icon-button

NOTE: The Material Web Components are distributed as ES2017 JavaScript Modules, and use the Custom Elements API. They are compatible with all modern browsers including Chrome, Firefox, Safari, Edge, and IE11, but an additional tooling step is required to resolve bare module specifiers, as well as transpilation and polyfills for Edge and IE11. See here for detailed instructions.

Example Usage

Standard

<mwc-icon-button icon="code"></mwc-icon-button>

SVG or Image

<mwc-icon-button>
  <svg slot="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>
</mwc-icon-button>

Disabled

<mwc-icon-button icon="code" disabled></mwc-icon-button>

Customize Colors

mwc-icon-button {
  color: tomato;
}

API

Slots

Name Description
icon Optional <img> or <svg> to display instead of using an icon font

Properties/Attributes

Name Type Default Description
icon string '' Icon to display, and aria-label value when label is not defined.
label string '' Accessible label for the button, sets aria-label.
disabled boolean false Disabled buttons cannot be interacted with and have no visual interaction effect.

Methods

None

Events

None

CSS Custom Properties

Name Default Description
--mdc-icon-font Material Icons Font to use for the icon.
--mdc-theme-text-disabled-on-light rgba(0, 0, 0, 0.38) Color of icon when disabled is true
--mdc-icon-button-ripple-opacity 0.12 Opacity of the ripple on the icon button

Additional references