Icon

Sizes any icon onto the glyph ladder and gives it one ink.

import { Icon } from "@usefragments/ui";Source

Preview

<Icon icon={Heart} />

Usage

Use when

  • A symbol sits beside text, inside a button, or leads a list item
  • State needs a glanceable marker

Avoid when

  • Artwork or illustration (use Image)
  • Multi-color or animated graphics

Implementation notes

  • Reserve the success, warning, and danger tones for real state
  • Hold one size per context
  • Use the bold weight beside strong text and fill for a filled state; regular everywhere else
  • Nothing above 24: a bigger glyph is an illustration, not an icon

Installation

pnpm add @usefragments/ui

Import styles once from @usefragments/ui/styles. See the installation guide for framework and theme setup.

Examples

Sizes

Steps tuned to the type scale, so icons never float off the baseline.

<div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
  <Icon icon={Star} size="xs" />
  <Icon icon={Star} size="sm" />
  <Icon icon={Star} size="md" />
  <Icon icon={Star} size="lg" />
  <Icon icon={Star} size="xl" />

Tones

One ink axis: the quiet text inks for glyphs beside secondary copy, the status inks for real state.

<div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
  <Icon icon={Heart} tone="secondary" />
  <Icon icon={Heart} tone="tertiary" />
  <Icon icon={Check} tone="success" />
  <Icon icon={Warning} tone="warning" />
  <Icon icon={Warning} tone="danger" />

Weights

Regular by default; bold beside strong text; fill for a filled state.

<div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
  <Icon icon={Heart} weight="regular" />
  <Icon icon={Heart} weight="bold" />
  <Icon icon={Heart} weight="fill" />
</div>

API reference

Component props
Prop
Type
Default
Description
iconRequiredAnyIconComponentNot setIcon component to render
sizeIconSize | undefinedxssmmdlgxlmdA step on the glyph ladder: xs 12, sm 14, md 16, lg 18, xl 24
toneIconTone | undefinedinfowarningdangeraccentsuccesssecondarytertiaryNot setThe glyph ink: secondary and tertiary follow the text ladder, accent is the accent ink, the status inks mark real state only. Omit to inherit currentColor
weightIconWeight | undefinedfillboldregularregularThe glyph weight, forwarded to icon components that take one
styleCSSProperties | undefinedNot set—

Accessibility

  • Icons ship aria-hidden — they are decoration until you label them
  • aria-label (or aria-labelledby) labels a meaningful icon: it renders role="img" and is no longer hidden
  • An icon-only button needs VisuallyHidden text
  • Color alone never carries the message
  • ButtonchildUse inside icon-only buttons with VisuallyHidden label
  • VisuallyHiddensiblingPair with VisuallyHidden for accessible icon-only elements
  • BadgechildCan be used as badge icon prop

Next steps