Skip to content

Icons

@xngui/icons
@xngui/icons

XIcon component, Font Awesome font import, size tokens, and accessibility.

Overview

Font Awesome via XIcon

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.

  1. Import font CSSOnce at the app root — before any icon renders@import '@xngui/icons/fontawesome'
  2. Import XIconPer component or shared icon moduleimport { XIcon } from '@xngui/icons'
  3. Render glyphShort name, optional style and size<x-icon name="star" />
Quick start
toolbar.html
<x-icon name="star" /><x-icon name="gear" style="regular" ariaLabel="Settings" /><x-icon name="spinner" [spin]="true" ariaLabel="Loading" />

Setup

Font import

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';
Package imports
ImportRole
@xngui/iconsXIcon component
@xngui/icons/fontawesomeFont Awesome stylesheet — required for glyphs

Styles & motion

Style families

XIconStyle covers Font Awesome Free families. Light, thin, and duotone are Pro-only and intentionally excluded.

  • star

    Default — filled glyphs

  • star

    Outlined glyphs

  • github

    Brand logos

Spin & mirror

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

Size scale

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

Common glyphs35

Search by glyph name. Click a cell to copy the name attribute value.

Accessibility

Decorative vs meaningful
  • 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

Inputs
InputTypeDefaultNotes
namestringGlyph name without fa- prefix
styleXIconStylesolidsolid · regular · brands
sizeXSize | undefinedinheritMaps to --x-icon-size-*; omit to inherit font-size
spinbooleanfalseContinuous rotation
mirrorbooleanfalseFlip horizontally for RTL chevrons
ariaLabelstring | undefinedRequired when icon is the only label

Playground

Interactive playground

Tune name, style, size, spin, and mirror in the component demo — code panel stays in sync.

Open icon demo