Skip to content

pantoken / plugins/pantoken/colors/src / darken

函数: darken()

darken(color, percent?): string

Beta

将 HSL 亮度降低 percent 点 — 这是 ui-color-utils darken 的纯 CSS 对应物 (tinycolor 会降低 HSL 亮度)。使用相对颜色语法以保留色相和饱和度。

In relative hsl(), the l channel resolves to a <number> on the 0–100 scale — the same scale tinycolor's amount uses — so the points are subtracted directly (no %).

参数

color

string

基础颜色。

percent?

number = 10

要减去的亮度点数(默认 10,与 tinycolor 的默认值一致)。

返回值

string

一个 hsl(from …) 相对颜色表达式。

示例

ts
darken("var(--brand)", 10); // "hsl(from var(--brand) h s calc(l - 10))"