API and Development
Icon renders mapped SVG paths for each SVGAsset with IconColor tokens, optional title for accessibility, fontSize, optional className, optional rotation for animated turns, and advanced renderPath for motion overrides.
Name | Type | Default | Description |
|---|---|---|---|
|
| — | The asset to render. |
|
|
| Whether rotation changes should animate via CSS on the wrapper. Set to |
|
| — | Additional CSS class name(s) applied to the icon wrapper. Useful for targeting child paths with CSS animations. |
|
| — | The color of the icon. |
|
|
| The font size of the icon. Can be a number (in px), a rem, or a px. |
|
| — | Morph configuration. When set, the icon renders in morph mode and does not support |
|
| — | Custom render function for each path element.
When provided, replaces the default |
|
| — | Clockwise rotation in degrees.
- When |
|
| — | The title of the icon. |
Interactive examples and edge cases for this component are in Storybook.
SVGAsset, IconColor, TextType, and usePrefersReducedMotion are exported from @prepared911/ui-core.
usePrefersReducedMotion is an SSR-safe hook that tracks the user's prefers-reduced-motion preference. Icon uses it internally for morphing animations; import it when other UI should respect the same preference.
Pass morph to animate when active toggles. Techniques are selected via IconMorphTechnique — pick explicitly to avoid accidental motion changes:
technique | Motion | When to use |
|---|---|---|
IconMorphTechnique.Crossfade (default) | Rotating crossfade (fade + 90° spin) | Topologically different pairs (Menu ↔ Dismiss, sun ↔ moon). Keeps existing CORE-544 motion. Requires to. |
IconMorphTechnique.Path | Interpolates paired path d attributes | Compatible siblings with equal geometry counts and matching topology (SortAscending ↔ SortDescending). Compound paths, holes, or opposite winding can produce malformed in-between frames; use crossfade for those pairs. Falls back to crossfade when counts differ. Resamples geometry only for the duration of the transition and restores the exact source geometry at rest, so idle icons are identical to non-morphing Icon. Requires to. |
IconMorphTechnique.PivotRotate | Path-morphs each subpath into its in-place invert | Compound paths that would weld as a single d and have no sibling target, such as ChevronUpDown on the Navbar app switcher. Uses the same interpolator as IconMorphTechnique.Path (SortAscending ↔ SortDescending). Does not take to. Idle markup matches a non-morphing Icon except that each subpath is its own <path>. |
Both path-morph states render their correct rest geometry during SSR and the initial client paint, including IconMorphTechnique.PivotRotate.
IconButton forwards the same morph object. Prefer IconMorphTechnique.Crossfade unless the pair was designed for path morphing, or IconMorphTechnique.PivotRotate for a compound path that should invert in place.
The previews below mirror the Icon stories in Storybook (Default, Colors, Sizes, Animation, InContext).
Voice equalizer uses the pr-voice-animation class (keyframes ship with @prepared911/ui-core icon styles).