GithubHelp home page GithubHelp logo

feathericons / react-feather Goto Github PK

View Code? Open in Web Editor NEW
1.9K 1.9K 126.0 1.09 MB

React component for Feather icons

Home Page: https://npm.im/react-feather

License: MIT License

JavaScript 100.00%
icons react react-components svg

react-feather's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-feather's Issues

Feature request: A way to get an icon based on the lowercase-dashed-format

I am working on an application where we allow users to set an icon name. We'd refer them to https://feathericons.com/ and say we support any of those icon names. In this library, you get an element reference with PascalCase format, as is conventional for a React element. It'd be convenient to have a way to get a reference to a React element from a dashed-format name. Something like this:

import * as Icon from 'react-feather';

...
const MyIcon = Icon.get('alert-circle');
// <MyIcon /> is now the same as <AlertCircle />
...

Universal Support

I see there's been a request for a react-native version #15 but could we try to have universal support by using svgs instead of react-native-svg so it supports both:

  • react
  • react-native
  • react-native-web

TypeScript type definitions

I love this library. Would it be possible to include TypeScript type definitions? This should be as simple as including a file named index.d.ts in the package and (optionally) adding the corresponding "types": "index.d.ts" line to the package.json.

I am attaching a rough and essentially simple draft of the type definitions for the library as of today:
https://gist.github.com/sgoll/bf270de030d339215f4964dbd50efc28

Request: Style icon with className

Would be great if the component can be styled with a className prop similar to react-icons.

Nevermind, it does work, I had my style sheet configured wrong. Thanks for this great package!

[ PenTool ] Not available

Hello, we plan on using your lib at my company.

However, the "PenTool" which we use, is not available.

How can I set icon dynamically?

In my app, icon names come from an external resource as strings for the navigation.

{
   "nav":[
      {
         "id":1,
         "title":"Home",
         "icon":"Home"
      }
   ]
}

I need something like;

<Icon name={item.icon} />

I couldn't find a way to create this icon dynamically, can't we do this?

Update to 4.19

A few icons have been added that would be lovely to have - can create a PR if it helps!

Feature Request

Can we add Todoist Done, Progress, and Pending icons to the feathericons?

Tree-shaking seems to be broken

Running webpack bundle analyzer, I am seeing every icon being included in my minified bundles:
screen shot 2017-11-14 at 8 11 56 am

Not sure if I am doing something wrong of if there is a problem in the package.

babelrc settings:

{
    "presets": [
        ["env", {
            "loose": true,
            "modules": false
        }], "react"
    ],
    plugins: [
        'syntax-dynamic-import',
        'transform-object-rest-spread',
        'transform-class-properties'
    ]
}

Why strokeWidth is not be passed as a property?

This is more of a question rather than an issue. But I see that for all icons, the strokeWidth is always set to 2. Except for the size and stroke, almost all SVG properties are directly assigned. Is the expectation to change them with CSS?

Is this repo dead?

I've noticed there has been practically no activity since April while there are several important issues and PRs with no response.
Especially #72 seems to be important with the new React release and how NPM handles peerDeps now, which can be difficult in projects.

@carmelopullara seems to be the primary maintainer; Will there be any more work on this repo?

Forking is of course an option, and I'd happily do so as I use this package in several projects, but I'd rather have this repo stay the main location for this library!

Forward ref to SVG graph

Some libraries rely on proper ref forwarding (e.g. see tippy.js docs mentioning it). Unfortunately right now none of the icon components forward ref, which can be improved with something like

import React, { forwardRef } from 'react';

const Activity = forwardRef((props, ref) => {
  const { color, size, ...otherProps } = props;
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      ...
      ref={ref}
    >
  ...

Change Icon Color onHover

Hello,

is there any easy way to add a hover effect e.g. when mouseOver change color to yellow?
I tried the following:

onMouseOver={(evt) => evt.target.setAttribute('style', 'stroke: gray')}
onMouseLeave={(evt) => evt.target.setAttribute('style', 'stroke: white')}

But this has got a problem with multiple paths. It does only color the selected path not all paths of the svg.

Spin an icon.

Is there a way to spin an icon?

Something like:

<Loader spin={true} />

When using non-ES6 imports, need to specify the exported default

From what I can tell, the README suggests the following approach to import the Camera component in the absence of ES6 imports:

var Camera = require('react-feather/dist/icons/camera');

However, the published dist/.../camera.js file exports like this:

exports.default = Camera;

Thus, it seems like the README should read:

If you can't use ES6 imports, it's possible to include icons from the compiled folder ./dist.

var Camera = require('react-feather/dist/icons/camera').default;

var MyComponent = React.createClass({
  render: function () {
    return (
      <Camera />
    );
  }
});

Or, perhaps, I am just missing something...

Ref is working with icons, but is not present on Icon type

I'm moving a project to TypeScript and I can't use ref :)

The code:

<Info size={ 14 } color="#BDC1C7" ref={ infoIcon } />

The compiler error:

Type error: Type '{ size: number; color: string; ref: MutableRefObject<SVGElement>; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
  Property 'ref' does not exist on type 'IntrinsicAttributes & Props & { children?: ReactNode; }'. Did you mean 'href'?

Not sure what type to use for forwardRef function component, but seems like FC doesn't include any ref property ๐Ÿค”

Add class="feather" attribute to SVG elements

Adding the class "feather" to SVG elements would make it easier to apply CSS styles to icons.

Following is an example an SVG element that include a CSS class from https://feathericons.com:

<svg class="feather feather-activity sc-dnqmqq jxshSx" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-reactid="36"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline></svg>

Add icon name prop

Does it not make sense to have a reusable icon component of our own that utilizes react-feather, and therefore be able to do something like <Icon icon={this.props.icon} />?

I'm aware that we can always pass an icon like <Camera /> down as a prop, but I'm wondering if it's possible to this just by the name of the icon.

Set as css `url`

Is there an option to set the icon as an css attribute? Something like


import { ArrowLeftCircle, ArrowRight } from 'react-feather';

domElement.style.cursor = ArrowLeftCircle?

Feature Request: Accessibility improvement / tooltip support

I have been using react-feather for a lot of my internal administration apps over the last year or so. It's very straight forward to work with and works well on all the devices that I develop for. Lately, we have been doing an accessibility audit on some of the applications and one of the things came up is the fact that when icons are used as "buttons" they are missing "alt text" / helpful info on what will happen.

I have been reading up on what seems to be the common way to achieve this with the inline SVGs as those react-feather produces. The most common option seems to be using a <title>-tag inside the element with the alt text that you want to show. I would love it if it was possible to set the "alt" attribute (like that used for

If the user does not specify the alt attribute, the icon should render as it always has to make sure it's backward compatible.

If the alt attribute is specified, I imagine that using, for example, the File icon like this:

<File alt="Navigate to report" />

should produce HTML along the following, the change being the <title>-tag inserted:

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    <title>Navigate to report</title>
    <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
    <polyline points="14 2 14 8 20 8"></polyline>
    <line x1="16" y1="13" x2="8" y2="13"></line>
    <line x1="16" y1="17" x2="8" y2="17"></line>
    <polyline points="10 9 9 9 8 9"></polyline>
</svg>

This will allow Chrome to display a tooltip when you mouse over the icon, just like the alt text of img tags:
image

Do you think this sounds like a reasonable change?

React Native version

Hi,

I created this React Native version based on your project: https://github.com/colmbrady/react-native-feather

It is basically a copy of your project, but the build script outputs React Native components.

Are you interested in supporting both React and React Native in your library? If you are, I would gladly work on a P.R into your project, and close mine.

Otherwise, if you have no interest, I will publish mine to NPM also.

Add used feather version to Readme

It would be really helpful, to have an info about what version of feather the current version of react-feather represents in the Readme. Even if it's just a small badge or something

After comparing changelogs/commit history this seems to currently be 4.7.x (with e.g. "coffee" from 4.8 yet missing)

I know that the goal would be to always be in sync as soon as possible, but it would be nice to not be in the dark if this is currently the case or not.

Thanks!

No PenTool component

I can't seem to use the following:

import * as Icon from 'react-feather'

...
render() {
    return <Icon.PenTool />
}

I also can't find it in the bit.dev website.

TS types aren't available

Hi ๐Ÿ‘‹

Trying to use this library in a TypeScript project and running into an issue because the types aren't actually available. In package.json I can see that the types should be in dist/index.d.ts but that file is never actually copied across from src during build ๐Ÿ‘

Thanks!

Invariant Violation

I'm getting an error:

Invariant Violation: View config not found for name path. Make sure to start component names with a capital letter.

This error is located at:
in path (created by LogOut)
in svg (created by LogOut)
in LogOut (at List.js:37)

In List.js (line 37) I used the icon like that:

<LogOut onPress={handleLogout} size={25} />

and imported like this:

import {LogOut} from 'react-feather';

Case Consistency

Is there a reason GitHub uses PascalCase while Gitlab uses Snakecase?

export { default as GitHub } from './icons/github';
export { default as Gitlab } from './icons/gitlab';

Proposal:
Change Gitlab to GitLab

React 17 Support

Hi,

Do you plan to upgrade to React 17 to avoid npm dependency conflict?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.