npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

feather-icons-react

v0.7.0

Published

Feather Icons as a React component.

Downloads

59,647

Readme

Feather Icons React

npm

yarn add feather-icons-react

This package lets you use Feather Icons as a React Component. It currently supports up to version 4.29.0

Usage

You can use the default export and pass the 'icon' prop:

import FeatherIcon from 'feather-icons-react';
<FeatherIcon icon="close" />;

Or you can use the provided named export in place of the icon prop:

import { Close } from 'feather-icons-react';
<Close />;

This gives you the flexibility to dynamically change the icon if you want to use the default export (like in the Toggle Icon example below), or potentially save on size in your application bundle by not having to require all of the icons by using the default export.

Setting a size:

Size can be passed as either string or number.

e.g.: <FeatherIcon icon="copy" size="24" /> or <Copy size={24} />

Sizes can always be easily overridden by CSS.

Setting fill and other properties

Fill defaults to none, but can be passed as a React prop

<FeatherIcon icon="heart" fill="red" />

Addtionally, you can add any other SVG tag properties, and they will pass through.

Setting colors

Use CSS. The icons default to use currentColor. This is equivalent to whatever text color is being used in the icon's container.

Dynamically change icons

Toggle icon example:

const ToggleIconContainer = () => {
  const [icon, setIcon] = useState('x');

  return (
    <div>
      <FeatherIcon icon={icon} />
      <ul>
        <li>
          <button onClick={() => setIcon('x')}>Make the Icon an X</button>
        </li>
        <li>
          <button onClick={() => setIcon('anchor')}>
            Make the Icon an Anchor
          </button>
        </li>
        <li>
          <button onClick={() => setIcon('box')}>Make the Icon a box</button>
        </li>
      </ul>
    </div>
  );
};

The icons are all square, based on a 24x24 grid.

The full list of icon names can be referenced at: feathericons.com

Contributing

To build the bundled assets for consumption yarn build

Updating the icons

If you found a missing icon, it is pretty easy to generate a new icons.json and get a PR up so this package stays in sync with the latest feather icons. Go into your desired project directory (ideally one directory above where you have feather-icons-react saved)

  1. git clone https://github.com/feathericons/feather.git
  2. cd feather && npx install
  3. npx babel-node bin/build-icons-json.js
  4. cp dist/icons.json ../feather-icons-react/src/icons.json
  5. Now open the file you just copied. Format the file, try to avoid entire green so the diff looks neat in the PR.

Alternatively, you can simply copy just the lines from the JSON file you know are missing. This is easier if you're just adding one new icon.

Testing your changes

You can use Storybook to verify your newly added icon is working as expected.

yarn storybook

This will open a new browser tab with the Storybook stories. You can type in the name of the icon and see it rendered in the main view.

TODO

  • Add tests both to the icon render and the generate icon exports script
  • Automatically generate new icons via script.
    • could copy build-icons-json script from feather-icons
  • verify react 18 support