iconoir/packages/iconoir-react/README.md

73 lines
2.2 KiB
Markdown
Raw Normal View History

2023-09-27 23:50:19 +02:00
# Iconoir - React
2021-05-19 00:56:52 +02:00
2023-09-27 23:50:19 +02:00
[![NPM Version](https://img.shields.io/npm/v/iconoir-react?style=flat-square)](https://www.npmjs.com/package/iconoir-react)
[![NPM Monthly Downloads](https://img.shields.io/npm/dm/iconoir-react?style=flat-square)](https://www.npmjs.com/package/iconoir-react)
[![NPM License](https://img.shields.io/npm/l/iconoir-react?style=flat-square)](https://github.com/iconoir-icons/iconoir/blob/main/packages/iconoir-react/LICENSE)
2021-05-19 21:21:53 +02:00
2023-09-27 23:50:19 +02:00
[Iconoir](https://iconoir.com/) is an open-source library with 1300+ unique SVG icons, designed on a 24x24 pixels grid. No premium icons, no email sign-up, no newsletters.
2021-05-19 00:56:52 +02:00
`iconoir-react` is an open source package that exports these icons as React.js components that can be used in all of your React projects.
## Installation
2021-05-19 00:56:52 +02:00
2023-09-27 23:50:19 +02:00
| npm | Yarn | pnpm |
| --------------------- | ------------------------ | ------------------------ |
| `npm i iconoir-react` | `yarn add iconoir-react` | `pnpm add iconoir-react` |
2021-05-19 00:56:52 +02:00
## Usage
2021-05-19 00:56:52 +02:00
```javascript
import React from 'react';
import { Iconoir } from 'iconoir-react';
const App = () => {
2023-09-27 23:50:19 +02:00
return <Iconoir />;
2021-05-19 00:56:52 +02:00
};
export default App;
```
Icons can take any standard SVG properties as optional props, e.g.
2023-09-27 23:50:19 +02:00
2021-05-19 00:56:52 +02:00
```javascript
<Iconoir color="red" height={36} width={36} />
2021-05-19 00:56:52 +02:00
```
2023-09-27 23:50:19 +02:00
Default values for the most common props are given below:
| Prop name | Default value |
2023-09-27 23:50:19 +02:00
| ----------- | -------------- |
| color | "currentColor" |
| width | "1.5em" |
| height | "1.5em" |
| strokeWidth | 1.5 |
### IconoirProvider
2021-05-19 00:56:52 +02:00
Tired of specifying the same props for every single icon, every time you use them? So were we. Use IconoirProvider to set the default icon props for everything inside IconoirProvider.
```tsx
2023-09-27 23:50:19 +02:00
import { IconoirProvider, Check } from 'iconoir-react';
return (
<IconoirProvider
iconProps={{
color: '#AAAAAA',
strokeWidth: 1,
width: '1em',
height: '1em',
}}
>
<SomeOtherContainer>
<Check />
</SomeOtherContainer>
</IconoirProvider>
2023-09-27 23:50:19 +02:00
);
```
## Icon names
2021-05-19 00:56:52 +02:00
2023-10-29 10:53:44 +01:00
The React components are named as PascalCase variations of their reference names (i.e. `airplane-helix-45deg` becomes `AirplaneHelix45deg`).
<SuggestLibrary />