JSPM

@rmwc/icon-button

3.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6231
  • Score
    100M100P100Q128590F
  • License MIT

RMWC IconButton component

Package Exports

  • @rmwc/icon-button
  • @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.

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="https://www2.le.ac.uk/departments/law/images/twitter-follow-us-icon"
  aria-label="Tweet it!"
/>

Usage as a Toggle

To use as a toggle, specify an additional toggled on state using 'onIcon'.

{/* Uncontrolled */}
<IconButton
  icon="favorite_border"
  onIcon="favorite"
/>

{/* 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="https://www2.le.ac.uk/departments/law/images/twitter-follow-us-icon"
  icon="https://en.facebookbrand.com/wp-content/uploads/2016/05/flogo_rgb_hex-brc-site-250.png"
/>

<IconButton
  onIcon={
    <div style={{ background: 'red', width: '24px', height: '24px'}} />
  }
  icon={
    <div style={{ background: 'green', width: '24px', height: '24px', borderRadius: '50%' }} />
  }
/>
import { DocumentComponent } from '@rmwc/base/utils/document-component';
import * as docs from './docgen.json';
import * as iconDocs from '@rmwc/icon//docgen.json';

<DocumentComponent docs={[docs, iconDocs]} component={IconButton} displayName="IconButton" composes={['Icon']} />