@i316/solar-react
v0.1.1
Published
i316: Solar icons as tree-shakeable React components.
Maintainers
Readme
@i316/solar-react
i316: Solar icons as React components. 1,454 icons in 6 styles: linear (default), bold, broken, bold-duotone, line-duotone, outline.
Other i316 Solar packages: @i316/solar-react-native (React Native), @i316/solar-vue (Vue 3), @i316/solar-angular (Angular) and @i316/solar-web (plain HTML web component and raw SVGs).
npm install @i316/solar-reactUsage
// One style: every icon is exported as both `Bell` and `BellIcon`.
import { AltArrowDown, BellIcon } from '@i316/solar-react/linear';
// Any style from the root: <Name><Style>Icon, or <Name>Icon to switch style at runtime.
import { BellBoldIcon, HomeIcon } from '@i316/solar-react';
<AltArrowDown size={20} color="#e11d48" />
<BellBoldIcon className="text-slate-500" title="Notifications" />
<HomeIcon variant={isActive ? 'bold' : 'linear'} />Works in React Server Components: icons can be rendered directly from server components (Next.js App Router).
Defaults for a whole subtree
import { SolarIconProvider } from '@i316/solar-react';
<SolarIconProvider size={20} color="currentColor" strokeWidth={2} className="shrink-0">
<App />
</SolarIconProvider>Props on an icon override the provider. Nested providers override their parent's values.
Icons chosen at runtime (CMS, user settings)
import { DynamicIcon, iconNames } from '@i316/solar-react/dynamic';
<DynamicIcon name={item.icon} variant="bold" fallback={<Spinner />} />Each icon is loaded as its own chunk the first time it renders. This is opt-in: only apps that import /dynamic pay for its map of every icon name.
Tree-shaking
Every icon is its own module and the package is sideEffects-free. Production builds in Vite, webpack, Rollup, esbuild and Next.js ship only the icons you import, whichever path you import from. <Name>Icon from the root includes every style of that one icon; import a specific style when you don't need switching.
Toolchains that don't tree-shake load a whole barrel for one named import: webpack in development, Jest, and anything else that runs modules unbundled. Two fixes:
Babel (Jest, webpack/babel-loader): add the bundled plugin. It rewrites import { Bell } from '…/linear' into import Bell from '…/linear/bell' at compile time.
// babel.config.js
module.exports = {
plugins: ['@i316/solar-react/babel'],
};Next.js (SWC, no Babel): use Next's own barrel optimization.
// next.config.js
module.exports = {
experimental: { optimizePackageImports: ['@i316/solar-react'] },
};Props
| Prop | Default | |
|---|---|---|
| size | 24 | width and height |
| color | currentColor | icon color |
| strokeWidth | 1.5 | linear, broken, line-duotone only; ignored by the other styles |
| secondaryColor | color | color of the translucent layer, bold-duotone, line-duotone only |
| secondaryOpacity | as designed | opacity of that layer, bold-duotone, line-duotone only |
| title | none | accessible name (see below) |
| variant | linear | <Name>Icon and DynamicIcon only: which style to render |
All other props pass through to the root <svg> (className, style, onClick, …), and ref is forwarded.
Accessibility: icons are decorative by default (aria-hidden="true"). Pass title to make one meaningful: it renders a <title> with role="img". Passing your own aria-label or role also removes aria-hidden.
Styling: every icon has the classes solar-icon solar-icon-<name> (e.g. solar-icon-alt-arrow-down), plus any className you pass.
Editor previews: hovering an icon imported from a style path (@i316/solar-react/linear) in VS Code (or any TypeScript editor) shows a picture of it. Root imports have no previews, which keeps them light for the editor.
Module format, TypeScript and Jest
ESM only, with TypeScript declarations included. moduleResolution "bundler", "node16" and legacy "node" all resolve every import path. Node 20.19+ and 22.12+ can require() it. Peer dependency: react >= 16.8.
Jest's default CommonJS mode needs it transformed by your Babel setup (babel-jest), the usual configuration for ESM-only packages. Adding the plugin above keeps each test file from loading every icon:
// jest.config.js
transformIgnorePatterns: ['/node_modules/(?!@i316/solar-react/)'],License
Icons: Solar Icon Set by 480 Design (https://github.com/480-Design/Solar-Icon-Set), licensed under CC BY 4.0. i316 modified them: recolored from the original hardcoded hex (#1C274C) to currentColor; reformatted, with some duotone groups and multi-path Bold icons consolidated into fewer paths (no intended visual change); seven icons renamed (e.g. cloud-file is now file-cloud); converted into React, React Native, Vue, Angular and web-component formats.
186 of the icons are not 480 Design's: they are Solar icon extensions by Hakim Saoudi (the @solar-icons project) (https://github.com/saoudi-h/solar-icons), licensed under MIT. LICENSE lists them, and meta.json in the web package marks them "origin": "extension".
i316 code (components, runtime, tooling): MIT, © 2026 rahil316. See LICENSE for both licenses in full.
