Skip to content

pantoken / design/swatches/src / toSvg

Fungsi: toSvg()

toSvg(swatches, options?): string

Eksperimental

Render swatches sebagai lembar spesimen SVG yang dikelompokkan.

Parameter

swatches

hanya-baca Swatch[]

Palet (mis. dari toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Mengembalikan

string

Dokumen SVG sebagai string.

Contoh

Render lembar spesimen untuk README

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

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

Hanya spesimen palet inti, dengan judul dan kisi yang lebih lebar

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