模組概覽#
若要產生像 'red' 這樣的人類可讀顏色,請使用 human()。若要產生像 #ff0000 這樣用於 HTML/CSS 的十六進位顏色,請使用 rgb()。也有其他顏色格式的方法,例如 hsl()、cmyk()、hwb()、lab() 和 lch()。
cmyk#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 CMYK 顏色格式。 |
colorByCSSColorSpace#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
| space | ColorFormat | 'sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb' | 要為其產生顏色的色彩空間。 |
cssSupportedFunction#
回傳:'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hwb' | 'cmyk' | 'lab' | 'lch' | 'color'
cssSupportedSpace#
回傳:'sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb'
hsl#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
| includeAlpha | boolean | false | 為顏色新增 alpha 值(RGBA)。 |
human#
hwb#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
lab#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
lch#
回傳一個 LCH 顏色。雖然 LCH 色彩空間中彩度的上限理論上是無 界的,但它被限制為 230,因為超過此值在瀏覽器中不會產生明顯差異。| 名稱 | 類型 | 預設值 | 說明 |
|---|
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
rgb#
| 名稱 | 類型 | 預設值 | 說明 |
|---|
| casing | Casing | 'lower' | 產生的十六進位顏色的字母大小寫。僅在使用 'hex' 格式時套用。 |
| format | ColorFormat | 'decimal' | 產生的 RGB 顏色格式。 |
| includeAlpha | boolean | 'false' | 為顏色新增 alpha 值(RGBA)。 |
| prefix | string | '#' | 產生的十六進位顏色前綴。僅在使用 'hex' 格式時套用。 |
space#
Modified at 2026-06-11 10:26:02