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.
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.
Color
Use color to set an individual icon's color. Leave it unset to inherit the surrounding text color through currentColor.
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:
Meters and progress
A few icon families represent levels or stages: Battery, Signal, Gauge, Meter, and ProgressTask.
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:
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.
- Both icons get the
nav-iconclass, - 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.
| Prop | Type | Description |
|---|---|---|
size | number | string | Sets width and height. Accepts a number or CSS length string; defaults to 16. |
width, height | number | string | Override the corresponding dimension from size. |
color | string | Sets the SVG color used by currentColor. Inherits the text color when omitted. |
className | string | Adds your classes after fy-icon and fy-{icon-name}. |
style | React.CSSProperties | Applies inline CSS styles. |
title | string | Adds an SVG title. Does not change the decorative accessibility default. |
aria-label | string | Names the icon and sets role="img" by default. |
aria-labelledby | string | References an external label. Also set role="img" and aria-hidden={false}. |
role | React.AriaRole | Overrides the icon's ARIA role. |
aria-hidden | boolean | "true" | "false" | Overrides whether the icon is hidden from assistive technology. |
ref | React.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:
Icons without an aria-label prop (or non-empty string) are given aria-hidden="true" by default. Leave this default when nearby text already explains the icon:
If the text is conditionally rendered (for example, hiding a label on mobile), prefer to visually hide the text instead of using display: none, so it remains available to screen readers.
Add aria-label when the icon communicates information on its own, such as when it illustrates a concept not represented by surrounding text. Often, an icon will stand in for a status:
In this case, the component sets role="img" and the aria-label is announced to screen readers. This is akin to setting alt on an <img> element.
For icon-only actions without a visible label, provide the accessible name on the parent and leave the icon decorative. This gives the control a single accessible name:
You wouldn't set aria-label in this case, as it would read twice.
A title or aria-labelledby alone does not change the decorative default. For an external label, set all three props:
Explicit role and aria-hidden props override the defaults. Empty or whitespace-only labels remain decorative.