Package Exports
- @rmwc/icon-button/README.md
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rmwc/icon-button) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Icon Buttons
Icon buttons allow users to take actions, and make choices, with a single tap.
- Module @rmwc/icon-button
- Import styles:
- import '@material/icon-button/dist/mdc.icon-button.css';
- MDC Docs: https://material.io/develop/web/components/buttons/icon-buttons/
Basic Usage
IconButton inherits from the Icon component and can be passed icons in the same way.
import { IconButton } from '@rmwc/icon-button';
<IconButton icon="star" label="Rate this!" />
<IconButton
icon="images/icons/twitter.png"
aria-label="Tweet it!"
tag="a"
href="https://twitter.com"
/>
<IconButton icon="favorite" label="Favorite" disabled/>
Usage as a Toggle
To use as a toggle, specify an additional toggled on state using 'onIcon'.
{/* Uncontrolled */}
<IconButton
icon="favorite_border"
onIcon="favorite"
/>
<IconButton
icon="favorite"
onIcon="favorite"
disabled
/>
{/* Controlled */}
<IconButton
checked={this.state.isChecked}
onClick={() => this.setState({isChecked: !this.state.isChecked})}
onIcon="star"
icon="star_border"
/>
<IconButton
onChange={(evt) => console.log(evt.detail)}
onIcon="images/icons/twitter.png"
icon="images/icons/facebook.png"
/>
<IconButton
onIcon={
<div style={{ background: 'red', width: '24px', height: '24px'}} />
}
icon={
<div style={{ background: 'green', width: '24px', height: '24px', borderRadius: '50%' }} />
}
/>import { Docs } from '@rmwc/base/utils/document-component';
import * as docs from './docgen.json';
<Docs src={docs} components={['IconButton']} />