Skip to content

React

Use typed icon components with size and color props, CSS classes, and standard React SVG props.

Installation

Install the package in a project with React 18.2+ or React 19:

Import an icon by name:

The package uses ESM and supports tree shaking, so a compatible bundler removes unused icons. Direct imports are also available:

For editable component source, follow the shadcn instructions. Those components accept the same props.

Size

Use size to set both dimensions. The original 16×16 viewBox stays the same when the icon scales.

16px
24px
32px
48px

Inline with text

Set size="1em" to match the surrounding font size. Use inline-block, inline-flex, or inline-grid to keep the SVG in the text flow.

Good morning Good morning Good morning

Color

Use color to set an individual icon's color. Leave it unset to inherit the surrounding text color through currentColor.

Inherited
Blue
Green
Violet

Or use a className; it will be added after the default classes:

See Styling for CSS examples. CSS color rules and inline styles can override the color prop, which is an SVG presentation attribute.

Usage with states

While the library primarily includes outline-style icons, a good number of them have filled or otherwise stateful variants where it makes sense. Instead of having to hack your own version, just find and use the corresponding variant instead.

Booleans

Icons with logical boolean use cases, like hearts and stars, have both outline and filled variants so you can swap between them when toggling. A few examples:

Media playback icons also have alternates for commonly-toggled actions:

0:42 / 3:18

Meters and progress

A few icon families represent levels or stages: Battery, Signal, Gauge, Meter, and ProgressTask.

IconBatteryMedium
IconSignalFour2
IconProgressTask50
IconGaugeSimple
Level
50%

If you find you're missing a step, families with fewer variants can reuse a state across multiple steps, or you can request an additional step by opening an issue. Choose thresholds that fit what your application represents:

Loading indicators

The library currently includes Loader, Spinner, and Rays, which can be combined with keyframe animations for indeterminate or loading states. Unlike other icons, the former two are duotone with additional paths at lower opacities, so you get the full effect:

IconSpinner
IconLoader
IconRays

Shared defaults with FyiProvider

In FYIcons 0.3.0 and later, FyiProvider lets a group of icons share size, color, className, or style. Import the provider and its icons from fyicons/client.

Home20px
All files20px
Saved files16px
  • Both icons get the nav-icon class,
  • the folder inherits the 20px size,
  • and the bookmark uses its own 16px size.

A nested provider can override defaults for a smaller group. Classes accumulate, and style properties merge from the outer provider to the inner provider to the icon, with the last value winning for each property.

Only icons imported from fyicons/client read these defaults. Use individual props or CSS for icons from fyicons, direct icon imports, and shadcn source icons.

API

All props are optional. Components also accept standard React SVG props and event handlers. Many icons use filled paths, so strokeWidth does not change their visual weight.

PropTypeDescription
sizenumber | stringSets width and height. Accepts a number or CSS length string; defaults to 16.
width, heightnumber | stringOverride the corresponding dimension from size.
colorstringSets the SVG color used by currentColor. Inherits the text color when omitted.
classNamestringAdds your classes after fy-icon and fy-{icon-name}.
styleReact.CSSPropertiesApplies inline CSS styles.
titlestringAdds an SVG title. Does not change the decorative accessibility default.
aria-labelstringNames the icon and sets role="img" by default.
aria-labelledbystringReferences an external label. Also set role="img" and aria-hidden={false}.
roleReact.AriaRoleOverrides the icon's ARIA role.
aria-hiddenboolean | "true" | "false"Overrides whether the icon is hidden from assistive technology.
refReact.Ref<SVGSVGElement>Gives access to the SVG element.

Accessibility

For non-decorative standalone icons, be sure to name the information or action that the icon represents. Based on your use case, you can take one of several different approaches: