Apidog Docs
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Learning Center
  • Back to home
  • Dynamic values Modules
  • Airline
  • Animal
  • Color
  • Commerce
  • Company
  • Database
  • Datatype
  • Date
  • Finance
  • Food
  • Git
  • Hacker
  • Helpers
  • Image
  • Internet
  • Location
  • Lorem
  • Music
  • Number
  • Person
  • Phone
  • Science
  • String
  • System
  • Vehicle
  • Word
  1. Learning Center

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#

Returns a CMYK color.
Parameters
| Name | Type | Default | Description |
| --- | --- |
| format | ColorFormat | 'decimal' | Format of generated CMYK color. |
Returns: string | number[]
Examples

colorByCSSColorSpace#

Returns a random color based on CSS color space specified.
Returns: string | number[]
Parameters
NameTypeDefaultDescription
formatColorFormat'decimal'Format of generated RGB color.
spaceColorFormat\sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb'Color space to generate the color for.
Examples

cssSupportedFunction#

Returns a random color based on CSS color space specified.
Returns: 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hwb' | 'cmyk' | 'lab' | 'lch' | 'color'
Examples

cssSupportedSpace#

Returns a random css supported color space name.
Returns: 'sRGB' | 'display-p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb'
Examples

hsl#

Returns an HSL color.
Parameters
NameTypeDefaultDescription
formatColorFormat'decimal'Format of generated RGB color.
includeAlphabooleanfalseAdds an alpha value to the color (RGBA).
Returns: string | number[]
Examples

human#

Returns a random human-readable color name.
Returns: string
Examples

hwb#

Returns an HWB color.
Parameters
NameTypeDefaultDescription
formatColorFormat'decimal'Format of generated RGB color.
Returns: string | number[]
Examples

lab#

Returns a LAB (CIELAB) color.
Parameters
NameTypeDefaultDescription
formatColorFormat'decimal'Format of generated RGB color.
Returns: string | number[]
Examples

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.
Parameters
NameTypeDefaultDescription
formatColorFormat'decimal'Format of generated RGB color.
Returns: string | number[]
Examples

rgb#

Returns an RGB color.
Parameters
NameTypeDefaultDescription
casingCasing'lower'FLetter type case of the generated hex color. Only applied when 'hex' format is used.
formatColorFormat'decimal'Format of generated RGB color.
includeAlphaboolean'false'Adds an alpha value to the color (RGBA).
prefixstring'#'Prefix of the generated hex color. Only applied when 'hex' format is used.
Returns: string | number[]
Examples

space#

Returns a random color space name from the worldwide accepted color spaces. Source: https://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses
Returns: string
Examples
Previous
Animal
Next
Commerce
Built with