@devigner-ui/icons-js: every icon as data, plus three functions that turn
it into SVG. No framework. The artwork is rendered from the React package at
build time, so the two cannot drift.
npm install @devigner-ui/icons-jsMark where icons go, then swap them in once:
<i data-icon="BagStraps" data-variant="bold" class="size-6"></i>import { createIcons, IconBagStraps } from "@devigner-ui/icons-js";
createIcons({ icons: { IconBagStraps } });Only the icons you pass can be drawn, so the page ships only those.
data-variant and data-stroke-width pick the drawing; every other
attribute (class, style, aria-label) moves onto the <svg>.
import { toSvg, toElement, IconAdd } from "@devigner-ui/icons-js";
el.innerHTML = toSvg(IconAdd, { variant: "bulk", attrs: { class: "size-6" } });
button.append(toElement(IconAdd));toSvg runs on a server too, for templates and emails. Each icon can also
be imported on its own:
import IconBagStraps from "@devigner-ui/icons-js/icons/BagStraps";| Option | Type | Default | What it does |
|---|---|---|---|
variant |
"outline" | "twotone" | "bold" | "bulk" | "broken" |
"outline" |
Which drawing to render |
strokeWidth |
string | number |
1.5 |
Line weight of outline, twotone and broken |
attrs |
object | {} |
Attributes for the <svg> |
Icons are decorative by default (aria-hidden="true"); an aria-label
in attrs makes one an image.