Skip to content

pantoken / design/swatches/src / toSvg

Fonction: toSvg()

toSvg(swatches, options?): string

Expérimental

Afficher les nuanciers sous forme de feuille d'échantillons SVG groupée.

Paramètres

swatches

lecture seule Swatch[]

La palette (p. ex. depuis toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Retourne

string

Le document SVG sous forme de chaîne.

Exemples

Générer une feuille d'échantillons pour un README

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

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

Échantillonner uniquement la palette principale, avec un titre et une grille plus large

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