Skip to the content

Icon

Icon renders a vector glyph that follows the surrounding text: it inherits currentColor and a 1em size unless you set color or size. Pass an icon from the Apollion set through icon; import each icon by name so the rest of the set is tree-shaken.
Typography & Media

When to use

Use when
  • A glyph represents an action or concept next to text, in buttons, lists or tables.
  • You need an icon from the Apollion set, or a custom SVG that follows the theme color.
Avoid when
  • The icon is the clickable element — use IconButton.
  • The icon sits beside a line of copy as one unit — use IconText.
  • The graphic is a logo or illustration — use Svg or Image.

Usage

import { Icon } from '@apollion-dsi/core/elements/icon';
import { userConfig } from '@apollion-dsi/core/icons';

<Icon icon={userConfig} size="xl" color="danger" />;

size takes a spacing-scale key or a number, resolved on the text-size axis: a sized icon grows with the app's textSize. Do not rebuild a name lookup with import * as icons in product code — it pulls the whole set into the bundle.

loading

Other sources

Pass a custom SVG element as children; the <svg> and its groups are painted with currentColor. src fetches an SVG from a URL and inlines it in the browser. It shows a 1em placeholder until the download finishes, so prefer icon or children. Use one source at a time: src wins over the others, then children, then icon.

<Icon size="xl" color="danger">
  <svg viewBox="0 0 24 24">
    <path d="…" />
  </svg>
</Icon>

<Icon src="/static/logo.svg" size="xl" />

Icon set

Click an icon to copy its name. sun, moon and desktop are the light, dark and system glyphs for a theme-mode picker.

Loading...Loading...Loading...Loading...Loading...

Accessibility

  • An icon is decorative by default. Add aria-hidden="true" when text next to it already carries the meaning.
  • For a meaningful standalone icon from the set, pass title: it renders as the SVG <title>.
  • An icon is not focusable. For an icon-only action, use IconButton with a label.

Properties

See also