1.0.1 • Published 5 years ago

@lil-icons/react v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

lil-icons

Demo

Installation

npm install @lil-icons/react

or

yarn add @lil-icons/react

Usage

Use icon as a common component:

import { IconSuccess } from '@lil-icons/react';

const MyComponent = () => (
  <div>
    <IconSuccess />
  </div>
);

You can use LilIconsContext to declare props once in the root component, they will be passed down to all the icons. It uses Context API:

import { LilIconsContext, IconSuccess } from '@lil-icons/react';

const App = () => (
  <div>
    <LilIconsContext.Provider value={{ color: 'green', width: 64, height: 64 }}>
      <IconSuccess /> // green 64x64
    </LilIconsContext.Provider>
  </div>
);

Icon props have a higher priority than provider props:

<LilIconsContext.Provider value={{ color: 'green' }}>
  <IconSuccess color="red" /> // red
</LilIconsContext.Provider>

You can get props from context in your custom components using withLilIconsContext:

import { withLilIconsContext } from '@lil-icons/react';

const SomeIcon = ({ width, height, color }) => (
  <svg width={width} height={height} color={color}>
    ...
  </svg>
);

const MyCustomIcon = withLilIconsContext(SomeIcon);

Props

PropTypeRequired
colorStringNo
widthString or NumberNo
heightString or NumberNo
1.0.1

5 years ago

1.0.0

5 years ago