dssoca docs
GitHub repository

Icon

The inline SVG icon set.

A small, token-sized SVG icon set. Built-in stroke glyphs are drawn from a `name` map; register your own with `registerIcon`, or pass raw `paths` inline. Decorative by default; pass a `title` to expose an accessible name. Supports `spin`, quarter-turn `rotate`, `flip`, an `outline`/`solid` `variant`, and configurable stroke.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Icon, registerIcon } from 'dssoca';

  registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>');
</script>

<Icon name="activity" />
<Icon name="settings" title="Settings" />
<Icon name="spinner" spin />
<Icon name="check" variant="solid" />
<Icon name="github" title="GitHub" />
<Icon name="language" />

Built-in glyphs: `grid`, `activity`, `database`, `logs`, `terminal`, `settings`, `user`, `arrow`, `chevron`, `external`, `film`, `note`, `book`, `check`, `cup`, `wallet`, `target`, `spinner`, `home`, `briefcase`, `folder`, `github`, `linkedin`, `language`, `color-swatch` (see the Gallery story). The `chevron` glyph has a bounding box centred (horizontally and vertically) on the 24×24 viewBox so a 180° rotation pivots about its visual centre without shifting (used by Accordion). Module exports `registerIcon(name, paths)` (re-exported from `dssoca`) to register or override a glyph globally at runtime, and the `IconName` / `IconSize` types. **House rule:** every component-drawn icon renders through this shared `Icon` component — no bespoke CSS-border shapes or ad-hoc inline `<svg>`; an *interactive* icon must sit inside a real control (a native `<button>` preferred) with the accessible name on the control and the icon marked `aria-hidden`. (Two deliberate non-icons: the Button loading indicator is a `Spinner`, and the Badge status dot is a styled span.)

Props

PropTypeDefaultDescription
nameIconNameRequired. Which glyph to render (e.g. grid, activity, terminal). Falls back to `paths` when unknown.
size'xs' | 'sm' | 'md' | 'lg'Icon-local fixed size scale — xs 12px / sm 16px / md 20px / lg 24px. `xs` is Icon-only (no global size-variant equivalent). When unset, inherits the active `--ss-icon` token (16/20/24 across sm/md/lg).
pxnumberExplicit pixel size; overrides the size scale.
pathsstringRaw SVG inner markup escape hatch — rendered when `name` is not a known/registered glyph.
titlestringAccessible name; rendered as a real <title> and wired via aria-labelledby (implies non-decorative).
descstringExtended description; rendered as <desc> and appended to aria-labelledby.
decorativebooleanForce aria-hidden with no a11y name. Defaults true when no `title`, false when a `title` is present.
spinbooleanfalseSpin the glyph (e.g. a loader). Honours prefers-reduced-motion.
rotate0 | 90 | 180 | 2700Quarter-turn rotation.
flip'horizontal' | 'vertical'Mirror the glyph.
variant'outline' | 'solid''outline'Stroked (outline) or filled with currentColor (solid).
strokeWidthnumber2Stroke weight in viewBox units.
absoluteStrokebooleanfalseKeep `strokeWidth` optically constant across sizes (recompute from resolved px).
classstring''Extra class on the root svg.