Skip to content

pantoken / formats/css/src / buildCssFile

函数: buildCssFile()

buildCssFile(__namedParameters): string

Beta

构建一个 CSS 文件字符串:已类型化的 @property 注册(顶层,主题无关),随后是一或多个作用域声明段(其选择器可能会被消费构建重写)。

参数

__namedParameters

comments

string[]

scope

string

properties?

PropertyRule[] = []

sections

CssSection[]

inherits?

boolean = true

返回值

string

示例

注册一个已类型化属性并输出一个作用域声明

ts
import { buildCssFile } from "@pantoken/css";

buildCssFile({
  comments: ["/* my tokens */"],
  scope: ":root",
  properties: [{ name: "--instui-color-brand", syntax: "<color>", value: "#0374b5" }],
  sections: [{ pairs: [["--instui-color-text-base", "var(--instui-color-brand)"]] }],
});

将一段内容包裹在 CSS 级联层中

ts
import { buildCssFile } from "@pantoken/css";

buildCssFile({
  comments: [],
  scope: ":root",
  sections: [{ layer: "pantoken", pairs: [["--instui-spacing-space-md", "1rem"]] }],
});