2021-10-01 09:19:36 +02:00
# Lucide React
Implementation of the lucide icon library for react applications
## Installation
2022-10-27 08:19:45 +02:00
```bash
2021-10-01 09:19:36 +02:00
yarn add lucide-react
2022-10-27 08:19:45 +02:00
```
2021-10-01 09:19:36 +02:00
2022-10-27 08:19:45 +02:00
or
2021-10-01 09:19:36 +02:00
2022-10-27 08:19:45 +02:00
```sh
2021-10-01 09:19:36 +02:00
npm install lucide-react
```
## How to use
2022-10-03 16:36:33 +02:00
It's build with ESmodules so it's completely tree-shakable.
2021-10-01 09:19:36 +02:00
Each icon can be imported as a react component.
### Example
You can pass additional props to adjust the icon.
2022-10-27 08:19:45 +02:00
```js
2021-10-01 09:19:36 +02:00
import { Camera } from 'lucide-react';
// Returns ReactComponent
// Usage
const App = () => {
2022-10-27 08:19:45 +02:00
return <Camera color="red" size={48} />;
2021-10-01 09:19:36 +02:00
};
export default App;
```
### Props
2022-10-27 08:19:45 +02:00
| name | type | default |
| ------------- | -------- | ------------ |
| `size` | _ Number _ | 24 |
| `color` | _ String _ | currentColor |
| `strokeWidth` | _ Number _ | 2 |
2021-10-01 09:19:36 +02:00
### Custom props
You can also pass custom props that will be added in the svg as attributes.
2022-10-27 08:19:45 +02:00
```js
2021-10-01 09:19:36 +02:00
// Usage
const App = () => {
2022-10-27 08:19:45 +02:00
return <Camera fill="red" />;
2021-10-01 09:19:36 +02:00
};
```
### One generic icon component
It is possible to create one generic icon component to load icons.
2022-10-27 08:19:45 +02:00
> :warning: Example below importing all EsModules, caution using this example, not recommended when you using bundlers, your application build size will grow strongly.
2021-10-01 09:19:36 +02:00
#### Icon Component Example
2022-10-27 08:19:45 +02:00
```js
2021-10-01 09:19:36 +02:00
import * as icons from 'lucide-react';
2022-10-27 08:19:45 +02:00
const Icon = ({ name, color, size }) => {
2021-10-01 09:19:36 +02:00
const LucideIcon = icons[name];
2022-10-27 08:19:45 +02:00
return <LucideIcon color={color} size={size} />;
2021-10-01 09:19:36 +02:00
};
export default Icon;
```