Icons
@xngui/icons@xngui/iconsXIcon component, Font Awesome font import, size tokens, and accessibility.
Overview
Use <x-icon> instead of raw <i class="fa-solid …">. Import the Font Awesome stylesheet once at the app root, then reference glyphs by short name (star, not fa-star).
Icons are font-based — load the stylesheet globally, import XIcon in components that render glyphs, then bind name and optional style.
- →
Import font CSSOnce at the app root — before any icon renders @import '@xngui/icons/fontawesome' - →
Import XIconPer component or shared icon module import { XIcon } from '@xngui/icons' Render glyphShort name, optional style and size <x-icon name="star" />
toolbar.html<x-icon name="star" /><x-icon name="gear" style="regular" ariaLabel="Settings" /><x-icon name="spinner" [spin]="true" ariaLabel="Loading" />Setup
The font import is global CSS — add it before components render icons. Tree-shaking does not apply to icon fonts; only import sets you use.
styles.css@import '@xngui/icons/fontawesome';import { XIcon } from '@xngui/icons';| Import | Role |
|---|---|
@xngui/icons | XIcon component |
@xngui/icons/fontawesome | Font Awesome stylesheet — required for glyphs |
Styles & motion
XIconStyle covers Font Awesome Free families. Light, thin, and duotone are Pro-only and intentionally excluded.
starDefault — filled glyphs
starOutlined glyphs
githubBrand logos
Use spin for loading indicators and mirror for directional chevrons in RTL layouts.
[spin]="true"Continuous rotation for loading
[mirror]="true"Horizontal flip for RTL chevrons
Sizes
Standalone icons map size to --x-icon-size-* tokens. Inline adornments inside controls inherit --x-control-icon-size from the [data-size] host. XSize in @xngui/core · control scale tokens.
--x-icon-size-xs0.75rem standalone icon--x-icon-size-sm1rem standalone icon--x-icon-size-md1.25rem standalone icon--x-icon-size-lg1.5rem standalone icon--x-icon-size-xl2rem standalone icon--x-control-icon-sizeInline adornment inside [data-size] controls
Glyph catalog
Search by glyph name. Click a cell to copy the name attribute value.
Accessibility
Favorite item Icons without ariaLabel are aria-hidden — use when adjacent text conveys meaning.
<x-icon name="star" />Icon-only buttons and status glyphs need ariaLabel so screen readers get a name.
<x-icon name="star" ariaLabel="Favorite" />
API
| Input | Type | Default | Notes |
|---|---|---|---|
name | string | — | Glyph name without fa- prefix |
style | XIconStyle | solid | solid · regular · brands |
size | XSize | undefined | inherit | Maps to --x-icon-size-*; omit to inherit font-size |
spin | boolean | false | Continuous rotation |
mirror | boolean | false | Flip horizontally for RTL chevrons |
ariaLabel | string | undefined | — | Required when icon is the only label |
Playground
Tune name, style, size, spin, and mirror in the component demo — code panel stays in sync.
Open icon demo