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))"