Icon Library
Free185 original glyphs on a 24px grid, drawn by name through one component once registered, or imported per icon. Only the glyphs you register or import ship. currentColor throughout, so an icon inherits its text colour in light and dark mode. Pro adds 514 more glyphs and the `sharp` and `duotone` weights.
import { SvIconComponent } from '@styloviz/icons/core';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Register the glyphs you name
A name is a string, and a bundler cannot see a string — so nothing is bundled by name. Import each glyph you draw by its subpath and register it once; the kit's own components register theirs. `provideSvIcons(svAllIcons)` (from `@styloviz/icons/registry`) is the explicit opt-in to every glyph, for an icon picker or a prototype. An unregistered name renders nothing and warns once in development.
import { provideSvIcons } from '@styloviz/icons'; import { arrowRightIcon } from '@styloviz/icons/glyph/arrow-right'; import { bellIcon } from '@styloviz/icons/glyph/bell'; bootstrapApplication(AppComponent, { providers: [provideSvIcons([arrowRightIcon, bellIcon])], }); // Or in the component that draws them: // protected readonly icons = registerSvIcons([bellIcon]);
Size and colour
`size` takes a token (sm · md · lg) or a number of pixels. Colour comes from the surrounding text — every glyph is stroked in `currentColor` — so a Tailwind `text-*` class on the icon or any ancestor is the whole styling story.
<sv-icon name="bell" size="sm" /> <sv-icon name="bell" [size]="28" /> <p class="text-red-600 dark:text-red-400"> <sv-icon name="alert-triangle" /> Payment failed </p>
Decorative or meaningful — the `title` decides
An icon beside its own label is decoration and must not be announced twice; an icon that IS the label needs a name. Setting `title` switches the glyph from `aria-hidden` to `role="img"`, which is why there is no separate `ariaLabel` input to get out of step with it.
<!-- Decorative: the text next to it already says this. --> <sv-button label="Download" icon="download" /> <span><sv-icon name="mail" /> hello@example.com</span> <!-- Meaningful: nothing else on screen carries this. --> <sv-icon name="check-circle" title="Verified account" />
Per-icon imports, for bundle-critical apps
A per-icon component carries its glyph with it, so there is nothing to register — the shortest path for a page that draws a handful of icons. The glyph-by-name component is the better fit where names come from data (a nav menu, a status map).
import { SvArrowRightIcon } from '@styloviz/icons/glyph/arrow-right'; import { SvCheckCircleIcon } from '@styloviz/icons/glyph/check-circle'; @Component({ imports: [SvArrowRightIcon, SvCheckCircleIcon], template: `<sv-arrow-right-icon size="lg" /><sv-check-circle-icon />`, }) export class CalloutComponent {}
Your own glyphs, resolved by the same component
`provideSvIcons` also takes a map of your own glyphs. They are consulted before the built-in ones, so a brand mark can be added without a second component and a built-in name can be overridden in one place rather than at every call site.
import { provideSvIcons } from '@styloviz/icons'; bootstrapApplication(AppComponent, { providers: [ provideSvIcons({ 'acme-logo': [{ tag: 'path', attrs: { d: 'M4 20 12 4l8 16Z' } }], }), ], }); // A provided name is not in the built-in union, so bind it rather than // typing it as a literal. <sv-icon [name]="brandMark" title="Acme" />
Flip and rotate, instead of a second glyph
A chevron pointing the other way is the same path mirrored. `flip` and `rotate` are applied around the centre of the viewBox, so the glyph stays on the grid and no extra bytes ship.
<sv-icon name="chevron-right" [rotate]="90" /> <sv-icon name="log-out" flip="horizontal" />
Pro weights
`sv-icon-pro` resolves your own glyphs first, then the Pro set, then the free set — every registered glyph in the kit through one tag (`provideSvIcons([brainProIcon])`, glyphs from `@styloviz-pro/icons/glyph/*`). It adds `sharp` (1.5 stroke, mitre joins, butt caps) and `duotone` (a stroked outline over a low-opacity `currentColor` fill) to the free `line` and `solid`.
<!-- provideSvIcons([brainProIcon, settings2ProIcon, checkIcon]) --> <sv-icon-pro name="brain" weight="duotone" size="lg" /> <sv-icon-pro name="settings-2" weight="sharp" /> <sv-icon-pro name="check" /> <!-- free glyphs resolve here too -->
When to use
Any icon in the kit — every component that takes an `icon` input resolves the name through this registry, so register the glyphs you hand it. You want one component that renders any glyph by name, with no sprite sheet, no icon font and no build step. Reach for the per-icon components when a page draws a few fixed icons and you would rather not register anything.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| namerequired | IconName | (string & {}) | — | Icon name. Built-in names are type-checked; registered custom names and registered Pro glyphs are also accepted. |
| size | IconSize | 'md' | Rendered size in px, or a named token (`sm`/`md`/`lg`). |
| strokeWidth | number | 1.75 | Stroke width in viewBox units (line weight only). |
| weight | IconWeight | 'line' | Visual weight. |
| title | string | null | null | Accessible label. When set the icon is exposed as `role="img"`; otherwise it is `aria-hidden`. |
| flip | IconFlip | null | Mirror the icon horizontally or vertically. |
| rotate | number | 0 | Rotate the icon clockwise, in degrees, around its centre. |
| cssClass | string | '' | Extra CSS classes applied to the root `<svg>` (e.g. Tailwind `text-*`). |
<sv-icon-pro>
Also in this family — SvIconProComponent from @styloviz-pro/icons.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| namerequired | IconProName | IconName | (string & {}) | — | Icon name — Pro and free built-in names are type-checked; custom names are also accepted. |
| size | IconSize | 'md' | Rendered size in px, or a named token (`sm`/`md`/`lg`). |
| strokeWidth | number | 1.75 | Stroke width in viewBox units (ignored by `sharp`). |
| weight | IconProWeight | 'line' | Visual weight: `line` · `solid` · `sharp` · `duotone`. |
| title | string | null | null | Accessible label. When set the icon is `role="img"`; otherwise it is `aria-hidden`. |
| flip | IconFlip | null | Mirror the icon horizontally or vertically. |
| rotate | number | 0 | Rotate the icon clockwise, in degrees, around its centre. |
| cssClass | string | '' | Extra CSS classes applied to the root `<svg>` (e.g. Tailwind `text-*`). |
Customization & theming
Resolve any glyph with `name`; size with `size` (sm · md · lg, or a number of pixels) and tune the stroke with `strokeWidth` (line weight only). Pick a `weight` — `line` or `solid` free; Pro adds `sharp` and `duotone` on `sv-icon-pro`. Orient with `flip` (horizontal · vertical) and `rotate` (degrees clockwise around the centre). Style the root `<svg>` through `cssClass` — a Tailwind `text-*` class is all a colour change takes, in either theme. Register glyphs with `provideSvIcons([...])` or `registerSvIcons([...])`; add or override with a map of your own, which is consulted before the built-in glyphs. Import per-icon components (`SvArrowRightIcon` from `@styloviz/icons/glyph/arrow-right`) for a fixed icon with nothing to register.
Best practices
Do: Set `title` only when the icon carries meaning nothing else on screen carries. An icon beside its own text label is decoration, and naming it makes a screen reader say the same thing twice. Do: Colour icons with a `text-*` class on the icon or an ancestor rather than a `fill`/`stroke` override — the glyphs are `currentColor`, so that is what makes them follow dark mode for free. Do: Register brand and product marks with `provideSvIcons` so they resolve through the same component as everything else, instead of an `<img>` that will not inherit colour or size. Tip: Use `rotate` / `flip` for a mirrored or turned glyph instead of shipping a second path. Do: Register exactly the glyphs you draw (`provideSvIcons([bellIcon, …])`). Opt into `svAllIcons` only where any name can appear — an icon picker — because it ships every glyph. Tip: `<sv-icon>` draws the free glyph of a name and, where the free set has none, a Pro glyph you registered (`provideSvIcons([folderPlusProIcon])`). That is what lets a free component such as `sv-button` take a Pro glyph as its `icon` in a Pro app. Don't: Don't name a glyph you have not registered — it renders NOTHING rather than falling back. That failure is invisible in review, so keep the development console open: an unregistered name warns there with the line to add.
Accessibility
An icon with no `title` is `aria-hidden` — the correct default, because most icons in a UI sit beside a label that already says what they mean, and announcing both reads the same word twice. Setting `title` promotes the glyph to `role="img"` with that string as its accessible name. One input drives both, so the role and the name can never disagree. Every glyph is stroked in `currentColor`, so contrast is inherited from the text colour that surrounds it and is fixed once for both themes rather than per icon. The glyphs sit on a 24px grid with consistent optical weight, so a row of icons stays legible at `sm` instead of one turning to mush. A name nobody registered renders nothing at all rather than a broken-image box, and warns once in development with the line to add. The kit's own build refuses a template of its own that names a glyph it does not register.
Feedback on Icon Library
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.