Skip to content

pantoken / design/swatches/src / toSvg

函数: toSvg()

toSvg(swatches, options?): string

实验性

将色板呈现为分组的 SVG 样本表。

参数

swatches

只读 Swatch[]

调色板(例如来自 toSwatches)。

options?

ToSvgOptions = {}

ToSvgOptions.

返回值

string

作为字符串的 SVG 文档。

示例

为 README 渲染样本表

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

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

仅对核心调色板进行样本展示,带标题和更宽的网格

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