Module: IconButton

MDCIconButton component implemented by react component.

Parameters:
Name Type Description
props Object

Attributes other than followings are passed to the button element of React as is.

Properties
Name Type Attributes Description
className string <optional>

The class name that is added to the root element.

icon string <optional>

The inner text of the icon element if adding the icon.

disablesMdcInstance boolean <optional>

Specifies true if you do not want to instantiate MDCRipple Component. Default to false.

mdcRippleRef React.MutableRefObject <optional>

MutableRefObject which bind an MDCRipple instance to. The instance is not bind if props.disablesMdcInstance is true.

Source:
Returns:
Type
DetailedReactHTMLElement
Example
import { IconButton } from 'material-react-js';

function MyFavoriteButton(props) {
  switch (props.type) {
    case 'material':
      return <IconButton className="material-icons" icon="favorite"/>;
      // The following code also returns the same output
      // return <IconButton className="material-icons">favorite</IconButton>;
    case 'image':
      return <IconButton><img src="./img/favorite.png" alt="favorite"/></IconButton>;
    case 'svg':
      return (
        <IconButton>
          <svg viewBox="0 0 32 32">...</svg>
        </IconButton>
      );
    default:
      throw new Error('unknown icon type');
  }
}