Icon @astryx-svelte/core v0.5.2 · Icon

Usage

Icons are small visual symbols that represent actions, objects, or concepts. They improve scannability and reinforce meaning alongside text. Supports both direct SVG components and semantic icon names that adapt to the active theme.
ts
import { Icon } from '@astryx-svelte/core';

Best practices

GuidancePractices
DoUse semantic icon names when available; they adapt to theme changes automatically.
DoOverride icons through the theme, not globally: defineTheme({icons: {close: <XMarkIcon />}}) scopes the swap to the active <Theme>, and extends shallow-merges it into derived themes. registerIcons() mutates a process-wide registry and warns in dev, so keep it for app bootstrap rather than making it a library's theming seam.
DoPair icons with text labels for accessibility; icon-only elements need an accessible label.
DoFor a meaningful standalone icon (no adjacent text), give it an accessible name via the label prop: it sets role="img" + aria-label and unhides the icon.
DoUse color tokens for icon colors, not hardcoded hex values.
DoBe mindful of context; decorative icons in compact components can distract rather than help.
Don'tUse icons as the sole means of conveying meaning; always provide a text alternative.
Don'tResize icons with arbitrary pixel values; use the provided size props.
Don'tMix icon styles (e.g. outline and filled) within the same context.
Don'tRender raw SVG elements; always wrap in Icon for consistent sizing and color.
Don'tPass a name prop; Icon uses icon (not name) to specify which icon to render.

Examples

Common configurations, variations, and states.
Icon — Non-Semantic Colors
Non-semantic color palette for icons.
Icon — Semantic Colors
All semantic icon color variants with labels.
Icon — Size Variants
All icon sizes from extra-small to large.
Icon — Status Indicators
Status list using semantic icons for success, warning, error, and info.