Skip to content

@absoluteui/icons

Icon registry, the built-in icons, and the AbsoluteUI icon set (@absoluteui/icons/set).

import { ... } from '@absoluteui/icons';

Components ask for icons by name. This package ships the AbsoluteUI icon set (@absoluteui/icons/set), resolves icon names, lets you add or replace icons (including whole third-party libraries such as Lucide, Font Awesome, and Material Symbols), sizes and layers them, and renders them as accessible elements. The Icons guide covers every option in depth.

How do I show an icon in my own markup, at a given size?

Section titled “How do I show an icon in my own markup, at a given size?”

renderIcon returns the element components use: decorative by default, an image with an accessible name when you pass label. size takes a theme size ('xs' 0.75rem, 'sm' 1rem, 'md' 1.25rem, 'lg' 1.5rem, 'xl' 2rem) or a CSS length.

import { renderIcon } from '@absoluteui/icons';
const decorative = renderIcon('check', { size: 'lg' });
decorative.getAttribute('aria-hidden'); // => 'true'
decorative instanceof SVGElement ? decorative.style.fontSize : ''; // => 'var(--aui-icon-size-lg, 1.5rem)'
const meaningful = renderIcon('check-circle', { label: 'Approved', size: '20px' });
[meaningful.getAttribute('role'), meaningful.getAttribute('aria-label')]; // => ['img', 'Approved']

How do I resize the icons of a component, a region, or the whole app?

Section titled “How do I resize the icons of a component, a region, or the whole app?”

Set --aui-icon-size on the component or any ancestor: every icon inside follows it (component icons, and those from renderIcon). To change the defaults everywhere, override the theme tokens --aui-icon-size-xs … --aui-icon-size-xl.

import { renderIcon } from '@absoluteui/icons';
const toolbar = document.createElement('div');
toolbar.style.setProperty('--aui-icon-size', '1.5rem'); // this region only
document.documentElement.style.setProperty('--aui-icon-size-sm', '1.125rem'); // app-wide default for small icons
toolbar.append(renderIcon('search'));

Install @fortawesome/free-solid-svg-icons (or another Font Awesome SVG package) and convert the icons you use with fromFontAwesome. Only the imported icons are in your bundle. Font Awesome Free icons are licensed CC BY 4.0: keep its attribution.

import { faCalendarDays, faUser } from '@fortawesome/free-solid-svg-icons';
import { fromFontAwesome, registerIcons, renderIcon } from '@absoluteui/icons';
registerIcons({ user: fromFontAwesome(faUser), calendar: fromFontAwesome(faCalendarDays) });
renderIcon('user').getAttribute('viewBox'); // => '0 0 448 512'

If you use Font Awesome’s web font instead, map names to its classes: { kind: 'class', className: 'fa-solid fa-user' }, and load its stylesheet yourself.

How do I use Material Symbols from Google Fonts?

Section titled “How do I use Material Symbols from Google Fonts?”

Load the font stylesheet from Google Fonts, allow its hosts in your CSP (webFontHosts.google from @absoluteui/theme), and register icons as ligatures: the element carries the font class and the icon name as text.

import { webFontHosts } from '@absoluteui/theme';
import { registerIcons, renderIcon } from '@absoluteui/icons';
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200';
document.head.append(link);
const csp = `style-src 'self' ${webFontHosts.google.styleSrc}; font-src 'self' ${webFontHosts.google.fontSrc}`;
registerIcons({ home: { kind: 'ligature', className: 'material-symbols-outlined', text: 'home' } });
const home = renderIcon('home');
[home.textContent, home.getAttribute('translate')]; // => ['home', 'no']
csp.includes('https://fonts.gstatic.com'); // => true

Material Icons (the older font) works the same way with className: 'material-icons'. Both are Apache 2.0 licensed.

How do I use Material Symbols or Material Icons as SVG instead of a font?

Section titled “How do I use Material Symbols or Material Icons as SVG instead of a font?”

SVG avoids loading a font and a third-party host. Take the path from the icon’s SVG file (for example from the @material-symbols/svg-400 package, imported as text by your bundler):

import homeSvg from '@material-symbols/svg-400/outlined/home.svg?raw';
import { registerIcons, renderIcon } from '@absoluteui/icons';
const viewBox = /viewBox="([^"]+)"/.exec(homeSvg)?.[1] ?? '0 -960 960 960';
const d = /\sd="([^"]+)"/.exec(homeSvg)?.[1] ?? '';
registerIcons({ home: { kind: 'svg', viewBox, paths: [d] } });
renderIcon('home').getAttribute('viewBox'); // => '0 -960 960 960'

How do I use Lucide, and make every component use it?

Section titled “How do I use Lucide, and make every component use it?”

Convert Lucide’s icon nodes with fromSvgNodes. A provider that maps the names components ask for to Lucide icons switches every component at once; unmapped names fall back to the built-in set.

import { Calendar, ChevronDown, Search, X } from 'lucide';
import { fromSvgNodes, resolveIcon, setIconProvider, type IconDefinition } from '@absoluteui/icons';
const lucideIcons: Readonly<Record<string, IconDefinition>> = {
close: fromSvgNodes(X),
'chevron-down': fromSvgNodes(ChevronDown),
calendar: fromSvgNodes(Calendar),
search: fromSvgNodes(Search),
};
setIconProvider({ resolve: (name) => lucideIcons[name] });
resolveIcon('close') === lucideIcons.close; // => true
resolveIcon('check').kind; // => 'vector' // not mapped: the built-in check

Lucide is ISC licensed. The same fromSvgNodes works for other sets that publish [tag, attributes] nodes.

How do I layer icons, for a badge or a counter?

Section titled “How do I layer icons, for a badge or a counter?”

A layers definition stacks icons and short texts in one icon. Each layer can be scaled, moved (in em), rotated, flipped, placed in a corner, and coloured with a theme tone. Label the whole icon once.

import { renderIcon } from '@absoluteui/icons';
const dot = { kind: 'svg', viewBox: '0 0 24 24', nodes: [['circle', { cx: 12, cy: 12, r: 12 }]] } as const;
const events = renderIcon({
kind: 'layers',
layers: [
{ icon: 'calendar' },
{ icon: dot, scale: 0.45, position: 'top-end', tone: 'error' },
{ text: '3', position: 'bottom-end', tone: 'error' },
],
}, { label: '3 events today', size: 'xl' });
[events.getAttribute('aria-label'), events.children.length]; // => ['3 events today', 3]

A provider is asked first for every name. Return a definition for the names you replace and undefined for the rest, which then come from the registry. setIconProvider(null) removes it.

import { builtInIcons, resolveIcon, setIconProvider, type IconDefinition } from '@absoluteui/icons';
const brand: Readonly<Record<string, IconDefinition>> = {
close: { kind: 'svg', viewBox: '0 0 20 20', stroke: true, paths: ['M5 5l10 10M15 5L5 15'] },
};
setIconProvider({ resolve: (name) => brand[name] });
resolveIcon('close') === brand.close; // => true
resolveIcon('check') === builtInIcons.check; // => true
setIconProvider(null);
resolveIcon('close') === builtInIcons.close; // => true

How do I change the icon of one component only?

Section titled “How do I change the icon of one component only?”

Pass a name or an inline definition in the component’s icons option (each component lists its icon slots in its API reference). Other instances are unaffected.

import { Spinner } from '@absoluteui/components/spinner';
const host = document.createElement('div');
document.body.append(host);
Spinner.create(host, { label: 'Saving', icons: { spinner: 'refresh' } });

Import the icons you use from @absoluteui/icons/set (each is its own module) and pass the definition to renderIcon. Pick a variant, set role colors, and add an overlay; the Icons guide lists every option and the API page shows every icon.

import { renderIcon } from '@absoluteui/icons';
import { downloadIcon, lockOverlay } from '@absoluteui/icons/set';
const download = renderIcon(downloadIcon, { variant: 'duotone', colors: { accent: '#16a34a' } });
download.querySelector('g[data-layer="secondary"]') !== null; // => true
download instanceof SVGElement ? download.style.getPropertyValue('--aui-icon-accent') : ''; // => '#16a34a'
const locked = renderIcon(downloadIcon, { overlays: [{ icon: lockOverlay }], label: 'Download locked' });
locked.querySelector('[data-overlay="lock"]') !== null; // => true

How do I change an icon’s colors or stroke width after rendering it?

Section titled “How do I change an icon’s colors or stroke width after rendering it?”

updateIcon restyles the icon in place (the element stays). Without a strokeWidth, icons follow the inherited --aui-icon-stroke-width (default 2), so a theme or a region can make all icons thinner or bolder.

import { renderIcon, updateIcon } from '@absoluteui/icons';
import { cloudUploadIcon } from '@absoluteui/icons/set';
const upload = renderIcon(cloudUploadIcon);
updateIcon(upload, { strokeWidth: 1.5, colors: { primary: '#2563eb' } });
upload instanceof SVGElement ? upload.style.getPropertyValue('stroke-width') : ''; // => '1.5'
document.documentElement.style.setProperty('--aui-icon-stroke-width', '2.5'); // every icon without its own strokeWidth

How do I animate an icon while something loads?

Section titled “How do I animate an icon while something loads?”

Icons are static until you start one of the animations the icon lists. A state trigger plays while the state lasts. Users who prefer reduced motion see the static icon.

import { animateIcon, getIconAnimation, renderIcon } from '@absoluteui/icons';
import { spinnerIcon } from '@absoluteui/icons/set';
const spinner = renderIcon(spinnerIcon, { label: 'Saving' });
document.body.append(spinner);
const motion = animateIcon(spinner, { preset: 'spin' });
motion.state; // => 'idle'
motion.setState('loading');
motion.setState('idle');
motion.dispose();
getIconAnimation(spinner); // => undefined
spinner.remove();

Unknown names, unsafe or malformed definitions, and invalid sizes fail loudly, with the icon’s name in the error. Shape nodes accept geometry, fill/stroke (none or currentColor), fill rules, and opacity only: no event handlers, styles, links, or scripts. TypeScript already rejects a size like 'huge'; the run-time check covers values from untyped configuration (the cast below simulates one).

import { fromSvgNodes, registerIcons, renderIcon, resolveIcon } from '@absoluteui/icons';
resolveIcon('no-such-icon'); // => throws ICON_UNKNOWN
registerIcons({ broken: { kind: 'svg', viewBox: '0 0 24', paths: ['M0 0'] } }); // => throws ICON_INVALID
fromSvgNodes([['circle', { cx: 12, onclick: 'alert(1)' }]]); // => throws ICON_INVALID
renderIcon('check', { size: 'huge' as '1px' }); // => throws ICON_INVALID_SIZE

Every icon of @absoluteui/icons/set, grouped by category, in each variant it provides, with the animations it lists. Use the category links or the search field to find an icon. Import an icon by its camel-cased name plus Icon (alarm-clock is alarmClockIcon) and an overlay plus Overlay (lockOverlay); see the icon set in the Icons guide.

animateIcon

Animate a vector icon with one of the presets its definition lists. Static until a trigger fires.

function animateIcon<L extends IconLayerName>(icon: Element, options: IconAnimationOptions<L>): IconAnimationController;

Example:

import { renderIcon, animateIcon, type VectorIcon } from '@absoluteui/icons';
const spinner: VectorIcon<'outline', 'base'> = { kind: 'vector', id: 'demo-spinner', viewBox: '0 0 24 24', animations: [{ preset: 'spin', trigger: 'loading' }], variants: { outline: [{ name: 'base', role: 'primary', paint: 'stroke', nodes: [['path', { d: 'M12 3a9 9 0 1 1-9 9' }]] }] } };
const icon = renderIcon(spinner, { label: 'Loading' });
const motion = animateIcon(icon, { preset: 'spin' });
motion.setState('loading');
motion.state; // => 'running'
motion.dispose();

getIconAnimation

The animation controller animateIcon attached to an icon.

function getIconAnimation(icon: Element): IconAnimationController | undefined;

setIconMotionPolicy

Application-level motion policy (never per instance from untrusted input).

function setIconMotionPolicy(next: IconMotionPolicy): void;

IconAnimationController

interface IconAnimationController {
readonly state: 'idle' | 'running';
play(): void;
stop(): void;
restart(): void;
setState(state: IconAnimationState): void;
dispose(): void;
}

IconAnimationOptions

interface IconAnimationOptions<L extends IconLayerName = IconLayerName> {
readonly preset: IconAnimationPreset;
readonly trigger?: IconAnimationTrigger;
readonly target?: L;
readonly durationMs?: number;
readonly delayMs?: number;
readonly easing?: string;
readonly iterations?: number;
readonly direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
readonly staggerMs?: number;
readonly host?: Element;
readonly essential?: boolean;
}

IconAnimationState

type IconAnimationState = 'idle' | 'loading' | 'success' | 'error';

IconMotionPolicy

'system' follows prefers-reduced-motion; 'reduce' never animates; 'allow-essential' also runs animations marked essential when the user prefers reduced motion.

type IconMotionPolicy = 'system' | 'reduce' | 'allow-essential';

fromFontAwesome

Converts a Font Awesome SVG icon definition (for example faUser from @fortawesome/free-solid-svg-icons) into an AbsoluteUI svg definition (filled with the text colour). Duotone definitions become one path per layer.

function fromFontAwesome(definition: FontAwesomeIconLike): IconDefinition;

Example:

fromFontAwesome({ icon: [448, 512, [], 'f007', 'M224 256a128 128 0 1 0 0-256z'] });
// => { kind: 'svg', viewBox: '0 0 448 512', paths: ['M224 256a128 128 0 1 0 0-256z'] }

fromSvgNodes

Converts [tag, attributes] shape nodes, the format of Lucide’s lucide package (fromSvgNodes(Users)) and similar icon sets, into an AbsoluteUI svg definition. Attributes are validated like every other icon; unsupported ones throw ICON_INVALID.

function fromSvgNodes(nodes: readonly (readonly [string, Readonly<Record<string, string | number | undefined>>])[], options?: FromSvgNodesOptions): IconDefinition;

Example:

fromSvgNodes([['circle', { cx: '12', cy: '12', r: '10' }], ['path', { d: 'M12 8v4' }]]).kind; // => 'svg'

registerIcons

Register or replace named icons in the built-in registry.

function registerIcons(icons: Readonly<Record<string, IconDefinition>>): void;

renderIcon

Render an icon element. Decorative by default; semantic when label is set.

function renderIcon<V extends IconVariantName, L extends IconLayerName>(icon: VectorIcon<V, L>, options?: RenderIconOptions<V, L>): Element;
function renderIcon(ref: IconRef, options?: RenderIconOptions): Element;

Example:

const icon = renderIcon('calendar', { size: 'lg' });
icon.getAttribute('aria-hidden'); // => 'true'
icon instanceof SVGElement ? icon.style.fontSize : ''; // => 'var(--aui-icon-size-lg, 1.5rem)'

resolveIcon

function resolveIcon(ref: IconRef): IconDefinition;

setIconProvider

Set a global icon provider. It is consulted before the registry, so a corporate icon set can replace every AbsoluteUI icon. null removes it.

function setIconProvider(next: IconProvider | null): void;

updateIcon

Update an icon from renderIcon in place (the element stays): colors and layer overrides restyle the existing shapes; variant, overlays, container, rotation, flips, and direction rebuild its content. Vector options need an AbsoluteUI vector icon; throws ICON_INVALID_OPTION otherwise.

function updateIcon(icon: Element, changes: UpdateIconOptions): void;

Example:

const icon = renderIcon('check', { label: 'Saved' });
updateIcon(icon, { label: null });
icon.getAttribute('aria-hidden'); // => 'true'

builtInIcons

Built-in icons: the names components use, drawn as outline icons of the AbsoluteUI icon set. Directional icons are not mirrored automatically: components pick direction-specific names themselves.

const builtInIcons: Readonly<Record<string, IconDefinition>>;

FontAwesomeIconLike

Shape of a Font Awesome icon definition (@fortawesome/*-svg-icons): icon is [width, height, ligatures, unicode, pathData]. Typed structurally; no Font Awesome import.

interface FontAwesomeIconLike {
readonly icon: readonly [number, number, unknown, unknown, string | readonly string[]];
}

FromSvgNodesOptions

interface FromSvgNodesOptions {
readonly viewBox?: string;
readonly stroke?: boolean;
readonly strokeWidth?: number;
}

IconLayer

One layer of a layers icon: an icon or a short text (a counter), optionally transformed, placed, and coloured. Offsets x/y are in em (fractions of the icon size).

interface IconLayer {
readonly icon?: IconRef;
readonly text?: string;
readonly scale?: number;
readonly x?: number;
readonly y?: number;
readonly rotate?: number;
readonly flip?: 'horizontal' | 'vertical' | 'both';
readonly position?: IconLayerPosition;
readonly tone?: IconTone;
readonly className?: string;
}

IconProvider

interface IconProvider {
resolve(name: string): IconDefinition | undefined;
}

RenderIconOptions

Options of renderIcon. The vector options (variant, colors, layers, overlays, container, stroke, rotation, flips, direction) apply to AbsoluteUI vector icons only.

interface RenderIconOptions<V extends IconVariantName = IconVariantName, L extends IconLayerName = IconLayerName> extends VectorRenderOptions<V, L> {
label?: string;
className?: string;
size?: IconSize | number;
doc?: Document;
}

UpdateIconOptions

Changes updateIcon accepts: accessible name, size, and the vector options.

interface UpdateIconOptions<V extends IconVariantName = IconVariantName, L extends IconLayerName = IconLayerName> extends VectorRenderOptions<V, L> {
label?: string | null;
size?: IconSize | number;
}

IconDefinition

type IconDefinition =
{
readonly kind: 'svg';
readonly viewBox: string;
readonly paths?: readonly string[];
readonly nodes?: readonly SvgNode[];
readonly stroke?: boolean;
readonly strokeWidth?: number;
}
| {
readonly kind: 'factory';
readonly create: (doc: Document) => Element;
}
| {
readonly kind: 'class';
readonly className: string;
}
| {
readonly kind: 'ligature';
readonly className: string;
readonly text: string;
}
| {
readonly kind: 'layers';
readonly layers: readonly IconLayer[];
}
| VectorIcon;

IconLayerPosition

Corner or centre of a layered icon, for badges and counters.

type IconLayerPosition = 'center' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';

IconRef

An icon name resolved through the provider/registry, or an inline definition.

type IconRef = string | IconDefinition;

IconSize

Theme icon sizes (icon-size-xs 0.75rem … icon-size-xl 2rem), or a CSS length such as '1.125rem' or '20px'.

type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | `${number}${'px' | 'rem' | 'em' | 'pt' | '%'}`;

IconTone

Colours a layer can take from the theme.

type IconTone = 'primary' | 'success' | 'warning' | 'error' | 'muted';

SvgNode

One SVG shape as [tag, attributes], the format Lucide and many icon sets publish. Geometry attributes are numbers or numeric strings; fill and stroke may be 'none' or 'currentColor'; fill-rule/clip-rule 'nonzero' or 'evenodd'; opacity 0 to 1.

type SvgNode = readonly [SvgNodeTag, Readonly<Record<string, string | number>>];

SvgNodeTag

SVG shape elements an svg definition may contain.

type SvgNodeTag = 'circle' | 'ellipse' | 'line' | 'path' | 'polygon' | 'polyline' | 'rect';

isVectorIcon

Whether a value is a vector icon definition (structure checked by assertVectorIcon).

function isVectorIcon(def: unknown): def is VectorIcon;

IconLayerOverride

Per-instance override of one layer.

interface IconLayerOverride {
readonly color?: string;
readonly opacity?: number;
readonly hidden?: boolean;
}

IconOverlayDefinition

A small mark composed onto a vector icon at an anchor (10x10 units, same stroke as the icon).

interface IconOverlayDefinition {
readonly kind: 'overlay';
readonly id: string;
readonly viewBox: '0 0 10 10';
readonly variants: {
readonly outline: readonly VectorLayer[];
readonly solid?: readonly VectorLayer[];
};
readonly mirror?: boolean;
}

IconOverlayPlacement

interface IconOverlayPlacement {
readonly icon: IconOverlayDefinition;
readonly anchor?: IconAnchor;
}

VectorAnimation

A curated animation an icon supports (only presets listed here can run on it).

interface VectorAnimation<L extends IconLayerName = IconLayerName> {
readonly preset: IconAnimationPreset;
readonly trigger: IconAnimationTrigger;
readonly target?: L;
readonly origin?: readonly [number, number];
}

VectorIcon

An AbsoluteUI icon: 24x24, one or more separately drawn variants. V and L name the variants and layers it has, so options for missing variants or layers do not type-check; VectorIcon alone accepts any icon.

interface VectorIcon<V extends IconVariantName = 'outline', L extends IconLayerName = IconLayerName> {
readonly kind: 'vector';
readonly id: string;
readonly viewBox: '0 0 24 24';
readonly variants: VectorVariants<V, L>;
readonly mirror?: boolean;
readonly anchors?: Readonly<Partial<Record<IconAnchor, readonly [number, number]>>>;
readonly animations?: readonly VectorAnimation<L>[];
readonly morph?: {
readonly to: string;
readonly layer: L;
readonly paths: readonly (string | null)[];
};
}

VectorLayer

One named layer of a variant: shapes painted in one role, in source (painter’s) order.

interface VectorLayer<L extends IconLayerName = IconLayerName> {
readonly name: L;
readonly role: IconColorRole;
readonly paint: 'stroke' | 'fill';
readonly opacity?: number;
readonly fillRule?: 'nonzero' | 'evenodd';
readonly nodes: readonly SvgNode[];
readonly knockout?: readonly SvgNode[];
}

VectorRenderOptions

Options that apply to vector icons.

interface VectorRenderOptions<V extends IconVariantName = IconVariantName, L extends IconLayerName = IconLayerName> {
readonly variant?: V;
readonly colors?: Readonly<Partial<Record<IconColorRole, string>>>;
readonly layers?: Readonly<Partial<Record<L, IconLayerOverride>>>;
readonly overlays?: readonly IconOverlayPlacement[];
readonly container?: 'circle' | 'square';
readonly strokeWidth?: number;
readonly strokeScaling?: 'scale' | 'fixed';
readonly rotate?: 0 | 90 | 180 | 270;
readonly flip?: 'horizontal' | 'vertical' | 'both';
readonly dir?: 'auto' | 'ltr' | 'rtl';
}

IconAnchor

type IconAnchor = 'bottom-end' | 'top-end' | 'center';

IconAnimationPreset

type IconAnimationPreset = 'spin' | 'pulse' | 'bounce' | 'wiggle' | 'shake' | 'draw' | 'reveal' | 'fade' | 'morph';

IconAnimationTrigger

type IconAnimationTrigger = 'idle' | 'hover' | 'focus' | 'press' | 'on-change' | 'loading' | 'success' | 'error' | 'manual';

IconColorRole

type IconColorRole = 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'error' | 'info' | 'muted';

IconLayerName

type IconLayerName = 'base' | 'secondary' | 'accent' | 'badge' | 'detail';

IconVariantName

type IconVariantName = 'outline' | 'solid' | 'duotone' | 'multicolor';