Icon
Icon is a semantic wrapper over Svg. It is decorative by default — hidden from assistive
technology — and becomes a labelled image the moment you give it an aria-label.
What it is
An Svg with two conveniences layered on. First, a size enum — xs through xl maps to a
pixel value, so icons stay consistent without a magic number at every call site. Second, an
accessibility default: with no aria-label, Icon sets aria-hidden and the glyph is skipped by
screen readers; with one, Icon drops aria-hidden and sets role="img", making it a labelled
image.
Glyphs come from either children (web-only inline SVG) or the render prop. The render form
receives the host platform's SVG primitives, so the same glyph source works on web and on native.
The @usemotif/icons package uses the render form throughout.
Install
Icon is exported from usemotif. No separate install.
API
Icon
stablefunction Icon(props: IconProps): JSX.Element
Size token (12 / 16 / 20 / 24 / 32px) or a raw pixel number.
Accessible label. When set, Icon becomes `role="img"` and drops `aria-hidden`. When omitted, the icon is decorative and hidden.
Render-prop receiving the platform SVG primitives — `Path`, `Circle`, `Line`, and the rest. Use this form for cross-platform glyphs.
Inline SVG content. Web-only — prefer `render` for glyphs that must work on native.
Every Svg attribute except `size` and `children`. `viewBox`, `stroke`, `fill`, and the rest pass through.
Accessibility
Most icons are decorative — they sit next to a text label that already carries the meaning. Icon
treats that as the default: no aria-label means aria-hidden, and the glyph is silent.
When the icon is the meaning — an icon-only button, a standalone status glyph — pass an
aria-label. Icon then sets role="img" and the label becomes the accessible name. The rule is
simple: if removing the icon would lose information, label it; if not, leave it decorative.
Cross-platform notes
On web children and render both work — children renders inline SVG JSX directly. On native
only the render form works; it receives react-native-svg primitives instead of DOM tags.
Author cross-platform glyphs with render so one source serves both targets.
Examples
A decorative icon beside a label:
A labelled, standalone icon:
A cross-platform glyph with render: