Skip to content

pantoken-root / design/swatches/src / toSvg

Funció: toSvg() ​

toSvg(swatches, options?): string

Experimental

Renderitzar mostres com a una fullana de mostra SVG agrupada.

Paràmetres ​

swatches ​

només de lectura Swatch[]

La paleta (p. ex., de toSwatches).

options? ​

ToSvgOptions = {}

ToSvgOptions.

Retorna ​

string

El document SVG com a cadena.

Exemples ​

Renderitzar una fullana de mostra per a un README

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

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

Mostrar només la paleta principal, amb un títol i una graella més ampla

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 });