Icon
A standardized SVG wrapper for the system’s glyphs and any icon you drop in.
Import
Section titled “Import”<script> import Icon from "@invisible-ui/svelte/Icon.svelte";</script><script setup> import { Icon } from "@invisible-ui/vue";</script>import { Icon } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-icon></ds-icon>In Elements, pass the glyph as a path or wrap its shapes in an <svg>:
<ds-icon label="Done" path="M20 6 9 17l-5-5"></ds-icon><ds-icon> <svg><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg></ds-icon>| Prop | Type | Default | Description |
|---|---|---|---|
size | string | "1em" | Width/height (scales with font-size by default). |
viewBox | string | "0 0 24 24" | SVG viewBox. |
strokeWidth | number | string | 2 | Stroke width in viewBox units. |
label | string | undefined | undefined | Accessible name; when omitted the icon is decorative. |
animation | "none" | "spin" | "pulse" | "none" | Built-in animation for the glyph: spin (continuous rotation, e.g. a loader) or pulse (opacity beat, e.g. a live indicator). Both respect prefers-reduced-motion (the icon stays visible, static). |
animationDuration | string | undefined | undefined | Animation duration (any CSS time, e.g. "0.8s"). |
| Prop | Type | Default | Description |
|---|---|---|---|
size | string | "1em" | Rendered size; 1em by default so icons scale with the surrounding text. |
viewBox | string | "0 0 24 24" | |
strokeWidth | number | string | 2 | Stroke width in viewBox units (glyphs are stroke-based by default). |
label | string | undefined | Accessible name. When omitted the icon is decorative (aria-hidden). |
Slots: default.
| Prop | Type | Default | Description |
|---|---|---|---|
size | string | "1em" | Rendered size; 1em by default so icons scale with the surrounding text. |
viewBox | string | "0 0 24 24" | |
strokeWidth | number | string | 2 | Stroke width in viewBox units (glyphs are stroke-based by default). |
label | string | — | Accessible name. When omitted the icon is decorative (aria-hidden). |
className | string | — | Extra classes merged onto the <svg> (e.g. for stateful styling). |
children | ReactNode | — | The glyph itself: <path>, <line>, <polyline>, … |
| Attribute | Reactive | Description |
|---|---|---|
path | yes | |
size | yes | |
view-box | yes | |
stroke-width | yes | |
label | yes |
Reactive attributes re-render the element when they change after the first render.
Accessibility
Section titled “Accessibility”- Decorative by default (
aria-hidden); passlabelto expose it as arole="img"with an accessible name. - Provide the glyph shapes (
<path>,<line>,<polyline>, …) via the default slot.
Example
Section titled “Example”<Icon label="Add"> <line x1="12" y1="5" x2="12" y2="19" /> <line x1="5" y1="12" x2="19" y2="12" /></Icon>