SolidJS
SolarProvider, useSolar, CSS variables, duotone, and stroke width for Solid 2 (@solar-icons/solid-v2) and Solid 1 (@solar-icons/solid).
npm install @solar-icons/solid-v2Requires solid-js and @solidjs/web ^2.0.0, and a Solid 2 JSX build (@solidjs/vite-plugin 3 or unplugin-solid 3 with "jsxImportSource": "@solidjs/web" in tsconfig.json).
The v2 in @solar-icons/solid-v2 refers to the Solid major version, not the Solar Icons
major version. Both @solar-icons/solid-v2 and @solar-icons/solid share the same Solar Icons
v2 API: identical import paths, component names, props, CSS variables, and CSS classes.
Import patterns
// Per-style (no style suffix - style in path)
import { HeartIcon } from '@solar-icons/solid-v2/bold'
// Single icon
import { HeartIcon } from '@solar-icons/solid-v2/bold/heart'
// Top-level (style suffix in name)
import { HeartBoldIcon } from '@solar-icons/solid-v2'Basic usage
import { HeartIcon } from '@solar-icons/solid-v2/bold'
function App() {
return <HeartIcon color="#ef4444" size={32} />
}Duotone
import { HeartIcon } from '@solar-icons/solid-v2/bold-duotone'
function App() {
return <HeartIcon color="#3b82f6" secondaryColor="#f59e0b" secondaryOpacity={0.4} size={48} />
}Stroke width
import { SettingsIcon } from '@solar-icons/solid-v2/linear'
function App() {
return <SettingsIcon strokeWidth={2} size={24} />
}SolarProvider
Uses Solid signals internally.
import { SolarProvider } from '@solar-icons/solid-v2'
import { HeartIcon } from '@solar-icons/solid-v2/bold'
function App() {
return (
<SolarProvider color="#3b82f6" size={24} strokeWidth={1.5}>
<HeartIcon />
</SolarProvider>
)
}useSolar
Returns Solid Accessors. Must be called inside a <SolarProvider>.
import { useSolar } from '@solar-icons/solid-v2'
function ColorToggle() {
const { color, setColor } = useSolar()
return <button onClick={() => setColor('#ef4444')}>Current: {color()}</button>
}Icon props
| Prop | Type | Description |
|---|---|---|
color | string | Icon color |
size | string | number | Width and height |
strokeWidth | string | number | Stroke width |
secondaryColor | string | Duotone accent color |
secondaryOpacity | number | Duotone accent opacity |
isolated | boolean | Ignores provider |
alt | string | Accessibility label |
All standard SVG attributes pass through.
CSS variables
Same as React.
CSS classes
Every icon renders with class solar plus solar-{name}-{style}. See the React page.
ESM only
Both @solar-icons/solid-v2 and @solar-icons/solid are ESM-only. require() does not work.
Solid 2 vs Solid 1
Solid 1 and Solid 2 differ in their compiler output, runtimes (solid-js/web became @solidjs/web), reactivity rules, and JSX types. One build cannot serve both without trade-offs in server rendering, hydration, and typing, so the two packages exist side by side. @solar-icons/solid remains actively maintained for Solid 1 and is not deprecated.
| Topic | @solar-icons/solid-v2 (Solid 2) | @solar-icons/solid (Solid 1) |
|---|---|---|
| Peer dependency | solid-js and @solidjs/web, ^2.0.0 | solid-js ^1.6.0 |
| JSX types | JSX from @solidjs/web | JSX from solid-js |
class | String, array, or object (Solid 2 class values) | String |
useSolar setters | Batched like any Solid 2 signal write: the DOM updates on the next flush | Apply right away |
| No provider | useSolar() throws Solid's context error | useSolar() throws |
See the @solar-icons/solid-v2 README and @solar-icons/solid README for full package metadata.
How is this guide?
Last updated on