Skip to main content

Icon

Info:Media
21

A functional glyph, or a mark generated from a name, drawn in the current text color.

glyph symbol svg pictogram mark

Live demo

live · @xtyle/astro

Icon

The functional set

chevron-up

chevron-down

chevron-left

chevron-right

chevron-expand

arrow-up

arrow-down

arrow-left

arrow-right

close

check

plus

minus

menu

more-vertical

more-horizontal

search

info

warning

error

success

external-link

maximize

dot

loader

play

pause

stop

skip-forward

skip-back

volume

volume-off

gear

folder

pencil

trash

eye

copy

palette

bookmark

download

Generated marks

A name that carries a spec (a -- grammar) is composed on the fly instead of looked up: primitives placed on a grid, sized, rotated, outlined, or knocked out, colored from the theme's own series so a mark recolors with the theme. See the grammar for the full syntax.

dice 3

dice-3

crest

crest

badge

badge

target

target

framed

framed

spun

spun

check badge

check-badge

search chip

search-chip

pennant

pennant

split

split

The same spec under a different scheme via colors:

chip chip chip

Text marks

The letter primitive typesets a glyph as a mark (--letter-A), so a monogram or initial composes like any other primitive: colored, framed, outlined, scaled. It draws in an indexed font slot (-f0 sans, -f1 display, -f2 mono), and a ---f finish swaps a slot for another theme font. A named web font renders only where it's loaded; theme-token fonts always work.

letter AA

letter A

display QQ

display Q

mono 77

mono 7

badged AA

badged A

framed NN

framed N

outlined RR

outlined R

Sizes

Tones

With no tone an icon inherits the surrounding text color; a tone tints it to a semantic role or named hue.

Spin

Loading

The loader glyph with spin is a lightweight busy indicator.

In controls

Transport controls

The media-transport glyphs (play, pause, stop, skip-back, skip-forward) drop into a run bar or a player the same way any glyph does, so a run / execute / start-stop control renders in one voice.

Inline

Press the to search, then to confirm or to dismiss.

Icon renders one glyph from a small functional set (chevrons, arrows, close, check, the status marks, a spinner, the menu dots, and the media-transport family: play, pause, stop, skip-forward, skip-back) as inline SVG. It carries no color of its own: the glyph is drawn in currentColor, so it inherits the text color around it and matches the derived theme with nothing to wire.

It sizes off the surrounding type by default, so an icon set beside a word lines up with it; size steps it in fixed em for a standalone glyph. An optional tone tints it to a semantic role or named hue, spin turns it into a loading affordance, and a label promotes it from decorative to a named image for assistive tech. Beyond the lookup, a name can carry a spec: a terse grammar (shield--star-s45-c1) the engine parses into a layered mark and composes on the fly, placing primitives on a grid, sizing, rotating, outlining, or knocking them out, and coloring them from the theme's own series via colors so a generated mark recolors with the theme. A parametric letter primitive typesets a glyph as a mark (--letter-A) in an indexed theme font slot (f0 sans, f1 display, f2 mono) that a ---f finish can swap for another theme font or a named web font. Lookup for the common glyph, generation for everything else, one element for both.

When to use

How this component composes with the rest of the set.

Drop an Icon inside a Button before or after the label for an icon-and-text control, or on its own in an icon-only button.
Set an Icon inline in Text at its default size to sit a glyph on the baseline mid-sentence.
Pair tone with a matching status glyph (success + tone="success") for a colored inline indicator.
Use spin on the loader glyph for a lightweight busy indicator where a full Spinner is too much.

Props

7 props, straight from the manifest.

PropTypeDefaultBindingsDescription
name IconName | string
chevron-up chevron-down chevron-left chevron-right chevron-expand arrow-up arrow-down arrow-left arrow-right close check plus minus menu more-vertical more-horizontal search info warning error success external-link maximize dot loader play pause stop skip-forward skip-back volume volume-off gear folder pencil trash eye copy palette bookmark download
html svelte astro
A functional-set glyph name, or a generated-mark spec (a name carrying a `--` grammar, e.g. `crest--shield-c1--star-s45-cf`). A plain name that is neither renders a visible placeholder box.
colors SeriesScheme
accents skittles statuses thermal status
accents
html svelte astro
For a generated mark, the series scheme its `c3+` color slots draw from (`accents`, `skittles`, `statuses`, …), so one spec re-skins across schemes. Ignored for a functional glyph.
size IconSize
sm md lg xl
md
html svelte astro
The glyph size, stepping in `em` off the surrounding text: `sm`, `md`, `lg`, `xl`. Omit to match the current text size.
tone FullTone
accent neutral danger success warn info accent-2 accent-3 accent-4 red orange yellow green blue purple brown pink cyan gray white black
html svelte astro
Tints the glyph to a semantic role (accent, success, danger, …) or a named hue (red … black). Omit to inherit the surrounding `currentColor`.
label string
html svelte astro
An accessible name. Set it and the icon is exposed as an image with this name; omit it and the icon is decorative and hidden from assistive tech.
spin boolean false
html svelte astro
Continuously rotates the glyph as a loading affordance. Honors `prefers-reduced-motion`.
static boolean false
astro
Astro only: emit the resolved light-DOM markup but never load the runtime to hydrate it, for a zero-JS glyph or mark. The Svelte and raw-element paths always upgrade, so they carry no equivalent.

Appearance

Sizes

sm

.xtyle-icon--sm

A compact glyph for dense inline hints.

md

default
.xtyle-icon

The default glyph, matching body text.

lg

.xtyle-icon--lg

A prominent glyph for a featured control.

xl

.xtyle-icon--xl

A large glyph for an empty-state or hero mark.

States

spin

.xtyle-icon--spin

Rotates continuously as a loading affordance; suppressed under reduced-motion.

Anatomy

The named parts that make up the component, with their selectors.

icon

.xtyle-icon

The <svg> glyph, drawn in currentColor on a 24×24 grid.

Tokens & coverage

What the component consumes, checked live against what the algorithm produces.

Success:fully covered 21/21 consumed tokens produced default register: 299 tokens

Live coverage check against the xtyle-default register (derive(xtyleDefault, { anchors })coverComponent(manifest, register)). Every token this component consumes must be a key the algorithm produces.

--accent --accent-2 --accent-3 --accent-4 --black --blue --brown --cyan --danger --gray --green --info --neutral --orange --pink --purple --red --success --warn --white --yellow

Accessibility

Decorative by default: with no label the icon is aria-hidden, so an adjacent text label carries the meaning and the icon is not announced twice.
Set label for a standalone icon that conveys meaning on its own (an icon-only button's glyph); it becomes role="img" with the name.
spin honors prefers-reduced-motion, freezing the glyph for users who ask for less motion.

Code

Glyphs and sizes

A few glyphs from the set, and the size steps.

<xtyle-icon name="search"></xtyle-icon>
<xtyle-icon name="check"></xtyle-icon>
<xtyle-icon name="chevron-right"></xtyle-icon>

<xtyle-icon name="menu" size="sm"></xtyle-icon>
<xtyle-icon name="menu" size="lg"></xtyle-icon>
<script lang="ts">
	import { Icon } from "@xtyle/svelte";
</script>

<Icon name="search" />
<Icon name="check" />
---
import Icon from "@xtyle/astro/Icon.astro";
---

<Icon name="search" />
<Icon name="check" />

Toned and spinning

A tone colors the glyph; spin turns the loader into a busy indicator.

<xtyle-icon name="success" tone="success"></xtyle-icon>
<xtyle-icon name="warning" tone="warn"></xtyle-icon>
<xtyle-icon name="error" tone="danger"></xtyle-icon>

<xtyle-icon name="loader" spin label="Loading"></xtyle-icon>
<script lang="ts">
	import { Icon } from "@xtyle/svelte";
</script>

<Icon name="success" tone="success" />
<Icon name="loader" spin label="Loading" />
---
import Icon from "@xtyle/astro/Icon.astro";
---

<Icon name="success" tone="success" />
<Icon name="error" tone="danger" />

Generated marks

A name carrying a spec is composed on the fly: primitives on a grid, sized / rotated / outlined / knocked out, colored from the theme's series via colors.

<!-- a name carrying a spec is composed, not looked up -->
<xtyle-icon name="crest--shield-c1--star-s45-cf" size="xl"></xtyle-icon>

<!-- a functional glyph rides as a charge by its bare name -->
<xtyle-icon name="check-badge--circle-c3--check-s55-cf" size="xl"></xtyle-icon>

<!-- a negative-space die: three pips knocked out of a rounded face -->
<xtyle-icon name="dice-3--square3-c1--dot-p7-s14-ko--dot-s14-ko--dot-p3-s14-ko" size="xl"></xtyle-icon>

<!-- the same spec re-skinned by scheme -->
<xtyle-icon name="chip--hex-c1--dot-s30-c2" colors="statuses" size="xl"></xtyle-icon>
<script lang="ts">
	import { Icon } from "@xtyle/svelte";
</script>

<Icon name="crest--shield-c1--star-s45-cf" size="xl" />
<Icon name="chip--hex-c1--dot-s30-c2" colors="statuses" size="xl" />
---
import Icon from "@xtyle/astro/Icon.astro";
---

<Icon name="crest--shield-c1--star-s45-cf" size="xl" />
<Icon name="chip--hex-c1--dot-s30-c2" colors="statuses" size="xl" />

Text marks

The letter primitive typesets a glyph as a mark, drawn in an indexed theme font slot (f0 sans, f1 display, f2 mono); a ---f finish swaps a slot for another theme font or a named web font, and iconFontImports returns the loading code for a named web font.

<!-- the letter primitive typesets a glyph; -f1 draws it in the display font -->
<xtyle-icon name="initial--letter-A" size="xl"></xtyle-icon>
<xtyle-icon name="mono--letter-7-f2" size="xl"></xtyle-icon>

<!-- a monogram badged, colored, and scaled like any primitive -->
<xtyle-icon name="badge--circle-c1--letter-A-cb-s55" size="xl"></xtyle-icon>

<!-- a ---f finish swaps a slot to a named web font (load it separately) -->
<xtyle-icon name="mark--letter-Q-f1---f1-noto+sans+symbols" size="xl"></xtyle-icon>
<script lang="ts">
	import { Icon } from "@xtyle/svelte";
</script>

<Icon name="initial--letter-A" size="xl" />
<Icon name="badge--circle-c1--letter-A-cb-s55" size="xl" />
---
import Icon from "@xtyle/astro/Icon.astro";
---

<Icon name="initial--letter-A" size="xl" />
<Icon name="badge--circle-c1--letter-A-cb-s55" size="xl" />