Returns a CMYK color.
Optional
options: { format?: StringColorFormat }Options object.
Optional
format?: StringColorFormatFormat of generated CMYK color.
Returns a CMYK color.
Optional
options: { format?: "decimal" }Options object.
Optional
format?: "decimal"Format of generated CMYK color.
Returns a CMYK color.
Optional
options: { format?: ColorFormat }Options object.
Optional
format?: ColorFormatFormat of generated CMYK color.
Returns a random color based on CSS color space specified.
Optional
options: {Options object.
Optional
format?: StringColorFormatFormat of generated RGB color.
Optional
space?: "sRGB" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb"Color space to generate the color for.
Returns a random color based on CSS color space specified.
Optional
options: {Options object.
Optional
format?: "decimal"Format of generated RGB color.
Optional
space?: "sRGB" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb"Color space to generate the color for.
Returns a random color based on CSS color space specified.
Optional
options: {Options object.
Optional
format?: ColorFormatFormat of generated RGB color.
Optional
space?: "sRGB" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb"Color space to generate the color for.
faker.color.colorByCSSColorSpace() // [0.93, 1, 0.82]
faker.color.colorByCSSColorSpace({ format: 'decimal' }) // [0.12, 0.21, 0.31]
faker.color.colorByCSSColorSpace({ format: 'css', space: 'display-p3' }) // color(display-p3 0.12 1 0.23)
faker.color.colorByCSSColorSpace({ format: 'binary' }) // (8-32 bits x 3)
Returns an HSL color.
Optional
options: { format?: StringColorFormat; includeAlpha?: boolean }Options object.
Optional
format?: StringColorFormatFormat of generated HSL color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
faker.color.hsl() // [201, 0.23, 0.32]
faker.color.hsl({ format: 'css' }) // hsl(0deg, 100%, 80%)
faker.color.hsl({ format: 'css', includeAlpha: true }) // hsl(0deg 100% 50% / 0.5)
faker.color.hsl({ format: 'binary' }) // (8-32 bits) x 3
faker.color.hsl({ format: 'binary', includeAlpha: true }) // (8-32 bits) x 4
Returns an HSL color.
Optional
options: { format?: "decimal"; includeAlpha?: boolean }Options object.
Optional
format?: "decimal"Format of generated HSL color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
Returns an HSL color.
Optional
options: { format?: ColorFormat; includeAlpha?: boolean }Options object.
Optional
format?: ColorFormatFormat of generated HSL color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
faker.color.hsl() // [201, 0.23, 0.32]
faker.color.hsl({ format: 'decimal' }) // [300, 0.21, 0.52]
faker.color.hsl({ format: 'decimal', includeAlpha: true }) // [300, 0.21, 0.52, 0.28]
faker.color.hsl({ format: 'css' }) // hsl(0deg, 100%, 80%)
faker.color.hsl({ format: 'css', includeAlpha: true }) // hsl(0deg 100% 50% / 0.5)
faker.color.hsl({ format: 'binary' }) // (8-32 bits) x 3
faker.color.hsl({ format: 'binary', includeAlpha: true }) // (8-32 bits) x 4
Returns an HWB color.
Optional
options: { format?: StringColorFormat }Options object.
Optional
format?: StringColorFormatFormat of generated RGB color.
Returns an HWB color.
Optional
options: { format?: ColorFormat }Options object.
Optional
format?: ColorFormatFormat of generated RGB color.
Returns a LAB (CIELAB) color.
Optional
options: { format?: StringColorFormat }Options object.
Optional
format?: StringColorFormatFormat of generated RGB color.
Returns a LAB (CIELAB) color.
Optional
options: { format?: "decimal" }Options object.
Optional
format?: "decimal"Format of generated RGB color.
Returns a LAB (CIELAB) color.
Optional
options: { format?: ColorFormat }Options object.
Optional
format?: ColorFormatFormat of generated RGB color.
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.
Optional
options: { format?: StringColorFormat }Options object.
Optional
format?: StringColorFormatFormat of generated RGB color.
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.
Optional
options: { format?: "decimal" }Options object.
Optional
format?: "decimal"Format of generated RGB color.
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.
Optional
options: { format?: ColorFormat }Options object.
Optional
format?: ColorFormatFormat of generated RGB color.
Returns an RGB color.
Optional
options: {Options object.
Optional
casing?: Casing$1Letter type case of the generated hex color. Only applied when 'hex'
format is used.
Optional
format?: "hex" | StringColorFormatFormat of generated RGB color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
Optional
prefix?: stringPrefix of the generated hex color. Only applied when 'hex' format is used.
faker.color.rgb() // '#0d7f26'
faker.color.rgb({ prefix: '0x' }) // '0x9ddc8b'
faker.color.rgb({ casing: 'upper' }) // '#B8A51E'
faker.color.rgb({ casing: 'lower' }) // '#b12f8b'
faker.color.rgb({ prefix: '#', casing: 'lower' }) // '#eb0c16'
faker.color.rgb({ format: 'hex', casing: 'lower' }) // '#bb9d17'
faker.color.rgb({ format: 'css' }) // 'rgb(216, 17, 192)'
faker.color.rgb({ format: 'binary' }) // '00110010 00001000 01110110'
faker.color.rgb({ includeAlpha: true }) // '#f96efb5e'
faker.color.rgb({ format: 'css', includeAlpha: true }) // 'rgba(180, 158, 24, 0.75)'
Returns an RGB color.
Optional
options: { format?: "decimal"; includeAlpha?: boolean }Options object.
Optional
format?: "decimal"Format of generated RGB color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
Returns an RGB color.
Optional
options: {Options object.
Optional
casing?: Casing$1Letter type case of the generated hex color. Only applied when 'hex'
format is used.
Optional
format?: "hex" | ColorFormatFormat of generated RGB color.
Optional
includeAlpha?: booleanAdds an alpha value to the color (RGBA).
Optional
prefix?: stringPrefix of the generated hex color. Only applied when 'hex'
format is used.
faker.color.rgb() // '#0d7f26'
faker.color.rgb({ prefix: '0x' }) // '0x9ddc8b'
faker.color.rgb({ casing: 'upper' }) // '#B8A51E'
faker.color.rgb({ casing: 'lower' }) // '#b12f8b'
faker.color.rgb({ prefix: '#', casing: 'lower' }) // '#eb0c16'
faker.color.rgb({ format: 'hex', casing: 'lower' }) // '#bb9d17'
faker.color.rgb({ format: 'decimal' }) // [64, 192,174]
faker.color.rgb({ format: 'css' }) // 'rgb(216, 17, 192)'
faker.color.rgb({ format: 'binary' }) // '00110010 00001000 01110110'
faker.color.rgb({ includeAlpha: true }) // '#f96efb5e'
faker.color.rgb({ format: 'css', includeAlpha: true }) // 'rgba(180, 158, 24, 0.75)'
faker.color.rgb({ format: 'decimal', includeAlpha: true }) // [52, 250, 209, 0.21]
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
Module to generate colors.
Overview
For a human-readable color like
'red'
, usehuman()
.For a hex color like
#ff0000
used in HTML/CSS, usergb()
. There are also methods for other color formats such ashsl()
,cmyk()
,hwb()
,lab()
, andlch()
.