Iconsax for React
iconsax-react is a React component library wrapping the Iconsax icon pack, offering 1000 distinct icons across six styles (Linear, Outline, TwoTone, Bulk, Broken, Bold), totaling 6000 variations. Currently at version 0.0.8, it's in early development, implying frequent updates and potential for rapid change. The library provides a vast collection of visually consistent, 24px grid-based icons, usable as standard React components with configurable `color`, `size`, and `variant` props. It aims to offer a comprehensive, style-flexible iconographic system for modern React applications.
Common errors
-
Module not found: Can't resolve 'iconsax-react'
cause The `iconsax-react` package has not been installed or there is a typo in the import path.fixRun `npm install iconsax-react` or `yarn add iconsax-react` to install the package. Double-check the import statement for correct spelling. -
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
cause Attempting to use an icon component without correctly importing it as a named export.fixEnsure the icon is imported with curly braces, e.g., `import { EmojiHappy } from 'iconsax-react';`. Avoid `import EmojiHappy from 'iconsax-react';`.
Warnings
- breaking The package is currently in a very early development phase (version 0.0.x). While not explicitly documented, minor or patch releases may introduce breaking changes without a major version increment (pre-1.0.0 semantic versioning behavior).
- gotcha Iconsax provides 6 different variants (Linear, Outline, TwoTone, Bulk, Broken, Bold). By default, icons render in the 'Linear' variant. For other styles, you must explicitly set the `variant` prop.
- gotcha Icon size can be specified as a number (e.g., `size={24}`) or a string (e.g., `size="2em"`). Incorrect units or unexpected string values might lead to rendering issues.
Install
-
npm install iconsax-react -
yarn add iconsax-react -
pnpm add iconsax-react
Imports
- EmojiHappy
const EmojiHappy = require('iconsax-react');import { EmojiHappy } from 'iconsax-react'; - Variant (type)
import type { Variant } from 'iconsax-react'; - Multiple Icons
import { EmojiHappy, Setting2, Notification } from 'iconsax-react/dist';import { EmojiHappy, Setting2, Notification } from 'iconsax-react';
Quickstart
import React from 'react';
import { EmojiHappy, Setting2, Notification } from 'iconsax-react';
const App = () => {
return (
<div style={{ display: 'flex', gap: '20px', alignItems: 'center', padding: '20px' }}>
<EmojiHappy size={48} color="#4CAF50" variant="Bulk" />
<Setting2 size={32} color="#FF9800" variant="TwoTone" />
<Notification size={24} color="#F44336" variant="Outline" />
<p>Click me!</p>
</div>
);
};
export default App;