The React package. Every icon is a component with full TypeScript types, and named imports tree-shake, so only the icons you use end up in your bundle.
What you can do:
- Import icons as components by their PascalCase name plus
Icon - Switch weight and appearance with one prop each
- Morph any icon into any other with
MorphIcon - Style with
className, Tailwind or inline styles: icons usecurrentColor - Render on the server: icons work in Next.js Server Components
Installation
The package installs straight from GitHub today; npm releases are coming. npm can't install a folder of a GitHub repo, so use pnpm or yarn for now.
pnpm add "github:Try-Openbase/icons#main&path:packages/icons-react"Basic usage
Import icons by name from @openbase/icons-react. Each one renders an <svg> and accepts every SVG prop.
import { BellIcon, HeartIcon, HomeIcon } from '@openbase/icons-react';
export function App() {
return (
<nav>
<HomeIcon size={24} />
<BellIcon size={24} weight="filled" />
<HeartIcon size={24} appearance="raised" color="#e11d48" />
</nav>
);
}Customizing icons
// Size: pixels, or any CSS length
<HomeIcon size={16} />
<HomeIcon size="1.5em" />
// Colour: defaults to currentColor
<HeartIcon color="#e11d48" />
// Weight
<StarIcon /> // outline (default)
<StarIcon weight="filled" />
// Appearance
<StarIcon appearance="raised" /> // glossy, engraved ink
<StarIcon appearance="drawn" /> // hand-drawn pen
// Any SVG prop
<HomeIcon className="text-slate-500" onClick={goHome} />Using with Tailwind CSS
Icons inherit currentColor, so Tailwind's text colour classes work as they are.
<HomeIcon className="size-5 text-slate-500 transition-colors hover:text-slate-900" />
<button className="flex items-center gap-2 text-emerald-600">
<ShieldCheckIcon size={20} weight="filled" />
Verified
</button>Props
Every icon component accepts these props, plus any standard SVG attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | string | 24 | Width and height: pixels or any CSS length |
| color | string | currentColor | Any CSS colour or variable |
| weight | "outline" | "filled" | "outline" | Icon weight |
| appearance | "flat" | "raised" | "drawn" | "flat" | Icon appearance |
| className? | string | - | Classes on the <svg>, next to openbase-icon |
| aria-label? | string | - | Makes the icon accessible; otherwise it's aria-hidden |
| ref? | Ref<SVGSVGElement> | - | Forwarded to the <svg> |
Icon weights
Every icon comes in two weights, drawn on the same 24 grid with the same shapes, so switching weight never moves anything.
Outline
weight="outline"
Filled
weight="filled"
<HomeIcon /> // outline (default)
<HomeIcon weight="filled" />Appearances
Each weight renders three ways:
- Flat: the icon as drawn.
- Raised: glossy, engraved ink: a gradient over the icon's own colour with soft inner edges. Painted at runtime, so it follows
color. - Drawn: the icon redrawn with a seeded hand-drawn pen. Generated from the flat icon, so it always matches.
Flat
appearance="flat"
Raised
appearance="raised"
Drawn
appearance="drawn"
<HeartIcon /> // flat (default)
<HeartIcon appearance="raised" />
<HeartIcon appearance="drawn" weight="filled" />Morphing
MorphIcon from @openbase/icons-react/morph animates from one icon to any other with spring physics; rotations come out of the geometry. Each icon exports morph data: Home, HomeFilled, HomeDrawn and HomeFilledDrawn.
Outline
Heart ↔ Star
Filled, raised
raised
Plus ↔ X
rotation from geometry
import { MorphIcon, Plus, X, Home, HomeFilled } from '@openbase/icons-react/morph';
// 1. Change the prop: it animates
<MorphIcon icon={open ? X : Plus} raised />
// 2. Drive the progress yourself (scrubbers, scroll, gestures)
<MorphIcon from={Home} to={HomeFilled} progress={0.4} />
// 3. Imperative
const ref = useRef<MorphHandle>(null);
<MorphIcon ref={ref} icon={Plus} />;
ref.current?.morphTo(X);| Prop | Type | Default | Description |
|---|---|---|---|
| icon | IconInput | - | The icon to show; changing it morphs |
| from / to / progress | IconInput / number | - | Controlled mode: the morph at progress (0–1) |
| spring | "snappy" | "smooth" | "bouncy" | "snappy" | Or { stiffness, damping } |
| raised | boolean | false | The raised appearance, riding the morph |
| size / color | number | string / string | 24 / currentColor | As on icon components |
| reducedMotion | "never" | "user" | "always" | "never" | "user" follows prefers-reduced-motion |
| label | string | - | Accessible name; without it the icon is hidden |
Styling & colour
Icons use currentColor, so without a color they take the text colour of their parent, raised included.
<div style={{ color: '#7c3aed' }}>
<HomeIcon /> {/* purple */}
<BellIcon appearance="raised" /> {/* purple, raised */}
</div>
<HeartIcon color="#e11d48" />
<HeartIcon color="hsl(245 82% 67%)" />
<HeartIcon color="var(--brand)" />Raised on dark surfaces
Two CSS variables set the raised appearance's inner edges: --openbase-raised-highlight (top-left) and --openbase-raised-edge (bottom-right).
.dark {
--openbase-raised-edge: rgb(0 0 0 / 0.4);
}Accessibility
Icons are decorative by default: they render with aria-hidden. Give an icon an aria-label (or aria-labelledby, or a title) when it carries meaning on its own.
// Decorative: the button has text
<button><TrashIcon /> Delete</button>
// Meaningful: an icon-only button
<button aria-label="Delete"><TrashIcon /></button>
// Morphs take a label, and can follow prefers-reduced-motion
<MorphIcon icon={liked ? HeartFilled : Heart} label="Like" reducedMotion="user" />Performance
- Named imports tree-shake:
import { HomeIcon } from '@openbase/icons-react'adds only that icon. - In
@openbase/icons-react/morph, import morph data by name (Heart,HeartFilled).MORPH_ICONSlooks icons up by file name, so it pulls in every icon's data (several megabytes). - Raised uses SVG filters and a mask; they're cheap at icon sizes, but avoid animating hundreds at once.
- Drawn icons are separate paths shipped with each component; flat is the lightest.
TypeScript
The package ships its own types. The ones you'll reach for:
import type { IconAppearance, IconWeight, OpenbaseIconProps, HeartIconProps } from '@openbase/icons-react';
import type { IconNode, MorphHandle, MorphIconProps, SpringPreset } from '@openbase/icons-react/morph';
type IconWeight = 'outline' | 'filled';
type IconAppearance = 'flat' | 'raised' | 'drawn';
interface OpenbaseIconProps extends SVGProps<SVGSVGElement> {
size?: number | string;
color?: string;
appearance?: IconAppearance;
}
// Each icon adds its weight
type HeartIconProps = OpenbaseIconProps & { weight?: IconWeight };Adding icons
Contributing an icon means drawing two SVGs, outline and filled, with the same file name. Everything else is generated: the drawn appearance, React components, Flutter assets, Compose vectors, and morph data for all three packages. Raised needs no files.
# 1. Draw and save both weights
data/icons/outline/rocket.svg
data/icons/filled/rocket.svg
# 2. Generate drawn, React, Flutter, Compose, morph data and the site's list
pnpm run generate:all
# 3. Build and check
pnpm run build:allThe full guide, including the drawing rules, is docs/ADDING_ICONS.md in the repository.
Troubleshooting
- `npm install` fails. npm can't install a folder of a GitHub repo. Use pnpm or yarn until the npm release.
- The icon is black. It follows
currentColor: set acolor, or a text colour on a parent. - Raised looks wrong after a theme switch. Set
--openbase-raised-edgefor dark surfaces (see Styling & colour). - Raised looks flat. It's subtle below 32px by design. Check it at 32px or larger.
- An icon is missing. Search the icons page: names follow the file names (
arrow-up-right→ArrowUpRightIcon,OpenbaseIcons.arrowUpRight).