React

The React package. Import icons as components with full TypeScript support. Everything is tree-shakeable, so only the icons you use end up in your bundle.

What you can do:

  • Import icons as individual React components
  • Set size, style, colour and stroke weight with props
  • Forward refs to the underlying SVG
  • Use it in Next.js, Vite, Remix, TanStack Start and more

Installation

Install the package with your package manager.

Basic Usage

Import icons by their PascalCase name from fmicon-react. Each icon is a React component.

App.jsx
import { Home, Notification, Lock } from "fmicon-react";

export default function Toolbar() {
  return (
    <nav className="toolbar">
      <Home size={24} />
      <Notification size={24} variant="bold" />
      <Lock size={24} color="#1265ec" />
    </nav>
  );
}

Customising Icons

Every icon takes the same options for size, style, colour and stroke weight.

Options
// Size
<Home size={16} />
<Home size={32} />

// Style
<Star />                       // linear (default)
<Star variant="bold" />
<Star variant="duotone" />

// Colour
<Heart color="#ff383c" />

// Stroke weight (line styles)
<Home strokeWidth={1} />

Direct Imports

Each icon also lives in its own module, named after its slug. Importing from there keeps only that one icon in your bundle, even without tree-shaking.

Direct import
import { Home } from "fmicon-react/icons/home";
import { Lock } from "fmicon-react/icons/lock";

Tip: Named imports from the main entry are tree-shaken by Vite, webpack and Rollup too. Direct imports are a guarantee for setups that don't tree-shake.

Full Example

A small toolbar with a few icons in different styles.

Complete example
import { Home, SearchNormal, Notification, Heart, Setting } from "fmicon-react";

export default function Toolbar() {
  return (
    <nav className="toolbar">
      <Home size={20} />
      <SearchNormal size={20} />
      <Notification size={20} variant="bold" />
      <Heart size={20} variant="bold" color="#ff383c" />
      <Setting size={20} strokeWidth={1} />
    </nav>
  );
}

Tip: Icons render plain SVG, so they work with server rendering in Next.js, Remix and TanStack Start.

Props

Everything an icon accepts. Other SVG attributes are passed straight through.

PropTypeDefaultDescription
sizenumber | string24Width and height in pixels
variant"linear" | "outline" | "bold" | …"linear"Any of the 8 styles, plus "glass-light"
colorstringcurrentColorAny CSS colour; glass keeps its own
strokeWidthnumber | string1.5Line weight for linear, twotone, broken and duotone
titlestring–Accessible name; without it the icon is hidden from screen readers

Styles

Every icon comes in 8 styles. Pick one with variant; the shape stays the same, so switching never shifts your layout.

Linear"linear"
Outline"outline"
Bold"bold"
Bulk"bulk"
Twotone"twotone"
Broken"broken"
Glass"glass"
Duotone"duotone"
Using styles
<Home />  {/* linear */}
<Home variant="bold" />
<Home variant="glass" />
<Home variant="glass-light" />  {/* glass for light backgrounds */}

Tip: A common pattern: linear for idle tabs and bold for the selected one.

Styling and Colour

Icons draw with currentColor, so with no colour set they take the text colour of their parent. That makes hover states, dark mode and theme colours work without extra code.

  • Inherit the parent's text colour (the default)
  • Pass any hex, RGB, HSL or CSS variable as the colour
  • Change the stroke weight on line styles: 1 thin, 1.5 default, 2 bold
  • Add classes with className, including Tailwind utilities
Colour
<Home color="#1265ec" />
<Home color="var(--brand)" />
<Home className="text-blue-500 hover:text-blue-600" />

Tip: Glass icons keep their own colours, so color doesn't change them. Use glass-light on light backgrounds.

Accessibility

Icons are hidden from screen readers (aria-hidden) unless you give them a name with title or aria-label.

Icon-only button
<button aria-label="Delete item">
  <Trash size={20} />
</button>
Icon with meaning
<Warning2 size={20} color="#ff383c" title="Warning" />

Tip: Next to visible text, leave the icon unnamed: the text already says it, and screen readers won't read it twice.

Performance

Packages are marked "sideEffects": false and every icon is its own module, so your bundle only gets the icons you import.

Imports
// Good: only these icons end up in the bundle
import { Home, Lock } from "fmicon-react";

// Avoid: pulls in all 891 icons
import * as Icons from "fmicon-react";
MethodBundle impactBest for
fmicon-react, /vue, /react-nativeOnly the icons you importApps with a bundler
…/icons/<slug>Exactly one icon per importSetups without tree-shaking
fmicon + toSvgOnly the icons you importVanilla JS, web components
CDN <img>Nothing in the bundleStatic sites, prototypes, email

TypeScript

Types ship with every package. Icon names autocomplete, and so do the styles.

Types
import type { IconProps, IconVariant, FMIcon } from "fmicon-react";

const variant: IconVariant = "duotone";

function NavItem({ icon: Icon, label }: { icon: FMIcon; label: string }) {
  return <a><Icon size={20} variant={variant} /> {label}</a>;
}

Troubleshooting

Common problems and how to fix them. Not listed? Open an issue on GitHub.

Icon name not found
// Components are PascalCase of the icon's slug
import { ArrowCircleRight, SearchNormal } from "fmicon-react";
// Clashes with a global? Every icon also has an Icon suffix
import { MapIcon, ImageIcon } from "fmicon-react";
Colour not changing
// Glass keeps its own colours; pick another style
<Home variant="bold" color="#1265ec" />
Stroke weight has no effect
// strokeWidth only applies to linear, twotone, broken and duotone
<Home variant="linear" strokeWidth={2} />