React

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 use currentColor
  • 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.

App.tsx
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

Props
// 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.

Tailwind CSS
<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>
Note: Icons render on the server too, so they work in Next.js Server Components and in any SSR framework without flashing.

Props

Every icon component accepts these props, plus any standard SVG attribute.

PropTypeDefaultDescription
sizenumber | string24Width and height: pixels or any CSS length
colorstringcurrentColorAny 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"

Using weights
<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"

Using appearances
<HeartIcon />                        // flat (default)
<HeartIcon appearance="raised" />
<HeartIcon appearance="drawn" weight="filled" />
Tip: Raised shows its shading best from 32px up; at 16–24px it reads as a soft gradient.

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

Morphing
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);
PropTypeDefaultDescription
iconIconInput-The icon to show; changing it morphs
from / to / progressIconInput / number-Controlled mode: the morph at progress (0–1)
spring"snappy" | "smooth" | "bouncy""snappy"Or { stiffness, damping }
raisedbooleanfalseThe raised appearance, riding the morph
size / colornumber | string / string24 / currentColorAs on icon components
reducedMotion"never" | "user" | "always""never""user" follows prefers-reduced-motion
labelstring-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.

Colour
<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).

CSS
.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.

Labels
// 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_ICONS looks 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:

Types
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.

In the repo
# 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:all

The 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 a color, or a text colour on a parent.
  • Raised looks wrong after a theme switch. Set --openbase-raised-edge for 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).
NextFlutter