Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any option to set icon size by default globally #40

Open
salih0313 opened this issue Jul 16, 2019 · 6 comments
Open

Is there any option to set icon size by default globally #40

salih0313 opened this issue Jul 16, 2019 · 6 comments

Comments

@salih0313
Copy link

How can i set icon size from 24 to some other size by default

@embee8
Copy link

embee8 commented Nov 10, 2019

I ended up solving this with a CSS rule:
image

@fdev
Copy link

fdev commented Nov 20, 2020

For backwards compatibility this library could use a Context that defines default icon options (which defaults to size 24px).
That way everyone can safely upgrade, but you could choose to use a different default size by adding the context:

import { FeatherContext, Camera, Clock, Compass } from "react-feather"

const App = () => (
  <>
    <Camera /> {/* color currentColor, size 24px */}

    <FeatherContext.Provider
      value={{
        size: "1em",
        color: "maroon",
      }}
    >
      <Clock /> {/* color maroon, size 1em */}
      <Compass size={32} /> {/* color maroon, size 32px */}
    </FeatherContext.Provider>
  </>
)

@jiayinghsu
Copy link

@fdev I noticed that the size attribute does not modify the viewBox size, which is fixed to be viewBox="0 0 24 24".

@fdev
Copy link

fdev commented Dec 30, 2020

@jiayinghsu I've since switched to react-icons which includes feather icons, defaults to 1em and provides the aforementioned context for overriding the defaults.

@Ayagoumi
Copy link

This is an ongoing issue, and it really frustrates me that I cannot change the size of the icon using the attribute.

@zhangyu1818
Copy link

I think it is possible to change the icon's defaultProps.

// icon.js
import * as icons from 'react-feather'

Object.values(icons).forEach((icon) => {
  icon.defaultProps = {
    size: '1em',
  }
})

export * from 'react-feather'
import { Home } from "./icon"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants