Color
Module to generate colors.Overview
For a human-readable color like 'red'
, use human()
.For a hex color like #ff0000
used in HTML/CSS, use rgb()
. There are also methods for other color formats such as hsl()
, cmyk()
, hwb()
, lab()
, and lch()
.
cmyk#
| Name | Type | Default | Description |
| --- | --- |
| format | ColorFormat | 'decimal'
| Format of generated CMYK color. |Returns: string | number[]
colorByCSSColorSpace#
Returns a random color based on CSS color space specified.Returns: string | number[]Name | Type | Default | Description |
---|
format | ColorFormat | 'decimal' | Format of generated RGB color. |
space | ColorFormat | \sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb' | Color space to generate the color for. |
cssSupportedFunction#
Returns a random color based on CSS color space specified.Returns: 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hwb' | 'cmyk' | 'lab' | 'lch' | 'color'
cssSupportedSpace#
Returns a random css supported color space name.Returns: 'sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb'
hsl#
Name | Type | Default | Description |
---|
format | ColorFormat | 'decimal' | Format of generated RGB color. |
includeAlpha | boolean | false | Adds an alpha value to the color (RGBA). |
Returns: string | number[]
human#
Returns a random human-readable color name.
hwb#
Name | Type | Default | Description |
---|
format | ColorFormat | 'decimal' | Format of generated RGB color. |
Returns: string | number[]
lab#
Returns a LAB (CIELAB) color.Name | Type | Default | Description |
---|
format | ColorFormat | 'decimal' | Format of generated RGB color. |
Returns: string | number[]
lch#
Returns an LCH color. Even though upper bound of chroma in LCH color space is theoretically unbounded, it is bounded to 230 as anything above will not make a noticeable difference in the browser.Name | Type | Default | Description |
---|
format | ColorFormat | 'decimal' | Format of generated RGB color. |
Returns: string | number[]
rgb#
Name | Type | Default | Description |
---|
casing | Casing | 'lower' | FLetter type case of the generated hex color. Only applied when 'hex' format is used. |
format | ColorFormat | 'decimal' | Format of generated RGB color. |
includeAlpha | boolean | 'false' | Adds an alpha value to the color (RGBA). |
prefix | string | '#' | Prefix of the generated hex color. Only applied when 'hex' format is used. |
Returns: string | number[]
space#
Modified atΒ 2025-01-02 08:45:43