Skip to content

pantoken / design/swatches/src / toSvg

Funzione: toSvg()

toSvg(swatches, options?): string

Sperimentale

Renderizza campioni come un foglio di esemplari SVG raggruppato.

Parametri

swatches

readonly Swatch[]

La palette (es. da toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Restituisce

string

Il documento SVG come stringa.

Esempi

Genera un foglio di esemplari per un README

ts
import { writeFileSync } from "node:fs";
import { swatches, toSvg } from "@pantoken/swatches";

writeFileSync("palette.svg", toSvg(swatches));

Mostra solo la palette principale, con un titolo e una griglia più ampia

ts
import { swatches, toSvg } from "@pantoken/swatches";

const core = swatches.filter((s) => !s.name.startsWith("primitive-"));
const svg = toSvg(core, { title: "Instructure core colors", columns: 8 });