3.0.0 • Published 3 years ago

@arterial/icon-button v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Arterial Icon Button

Another React Material Icon Button

Installation

npm install @arterial/icon-button

Usage

Styles

Sass

@use "@material/icon-button/index.scss" as icon-button;
@include icon-button.core-styles;

CSS

import '@material/icon-button/dist/mdc.icon-button.css';

JSX

import {IconButton} from '@arterial/icon-button';

Regular Icon Button

<IconButton icon="favorite" />

Toggle Button

function Toggle() {
  const [on, setOn] = useState(false);
  return (
    <IconButton
      icon="favorite_border"
      iconOn="favorite"
      on={on}
      onClick={() => setOn(!on)}
    />
  );
}

Other Variants

Image

Icon buttons can be used with img tags.

<IconButton
  icon={
    <img
      src="https://instagram-brand.com/wp-content/uploads/2016/11/Instagram_AppIcon_Aug2017.png"
      alt="instagram"
    />
  }
/>

Toggle Image

Icon button toggles can be used with img tags.

function ToggleImage() {
  const [on, setOn] = useState(false);
  return (
    <IconButton
      icon={
        <img
          src="https://en.facebookbrand.com/wp-content/uploads/2019/04/f_logo_RGB-Hex-Blue_512.png"
          alt="facebook"
        />
      }
      iconOn={
        <img
          src="https://instagram-brand.com/wp-content/uploads/2016/11/Instagram_AppIcon_Aug2017.png"
          alt="instagram"
        />
      }
      on={on}
      onClick={() => setOn(!on)}
    />
  );
}

SVG

Icon buttons can be used with svgs.

<IconButton icon={<FirefoxSvg />} />

Toggle SVG

Icon button toggles can be used with svgs.

function ToggleSvg() {
  const [on, setOn] = useState(false);
  return (
    <IconButton
      icon={<ChromeSvg />}
      iconOn={<FirefoxSvg />}
      on={on}
      onClick={() => setOn(!on)}
    />
  );
}

Props

IconButton

NameTypeDescription
classNamestringClasses to be applied to the root element.
iconstring | nodeIcon to render within root element. Displays when toggle is "off".
iconOnstring | nodeIcon to render within root element. Displays when toggle is "on".
labelstringSets the aria-label on root element.
onbooleanIndicates the toggle is on.
styleobjectStyles to be applied to the root element.
tagstring | objectHTML tag to be applied to the root element. Defaults to button.
3.0.0

3 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.6

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.1

4 years ago

1.0.0-alpha.0

4 years ago