Skip to main content

color Domain

The color domain maps domain keywords to underlying faker implementations.

Faker Documentation

Methods

color.cmyk

Returns a CMYK color.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated CMYK color.

Examples:

Shows color.cmyk when optional params are omitted.

color.cmyk()

Returns: [0.42,0.72,0,0.3]

Shows color.cmyk using format.

color.cmyk(format="decimal")

Returns: [0.42,0.72,0,0.3]

color.colorByCSSColorSpace

Returns a random color based on CSS color space specified.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated RGB color.
spacesRGB|display-p3|rec2020|a98-rgb|prophoto-rgbnoColor space to generate the color for.

Examples:

Shows color.colorByCSSColorSpace when optional params are omitted.

color.colorByCSSColorSpace()

Returns: [0.417,0.7203,0.0001]

Shows color.colorByCSSColorSpace using format.

color.colorByCSSColorSpace(format="decimal")

Returns: [0.417,0.7203,0.0001]

Shows color.colorByCSSColorSpace using space.

color.colorByCSSColorSpace(space="display-p3")

Returns: [0.417,0.7203,0.0001]

color.cssSupportedFunction

Returns a random css supported color function name.

No parameters.

Examples:

Shows the default color.cssSupportedFunction call.

color.cssSupportedFunction

Returns: hsla

color.cssSupportedSpace

Returns a random css supported color space name.

No parameters.

Examples:

Shows the default color.cssSupportedSpace call.

color.cssSupportedSpace

Returns: rec2020

color.hsl

Returns an HSL color.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated HSL color.
includeAlphabooleannoAdds an alpha value to the color (RGBA).

Examples:

Shows color.hsl returning the default tuple output.

color.hsl

Returns: [150,0.72,0]

Shows color.hsl returning CSS text without alpha.

color.hsl(format="css")

Returns: hsl(150deg 72% 0%)

Shows color.hsl including alpha while keeping the tuple-style output.

color.hsl(includeAlpha=true)

Returns: [150,0.72,0,0.3]

Shows color.hsl returning CSS text with alpha included.

color.hsl(format="css", includeAlpha=true)

Returns: hsl(150deg 72% 0% / 30)

color.human

Returns a random human-readable color name.

No parameters.

Examples:

Shows the default color.human call.

color.human

Returns: magenta

color.hwb

Returns an HWB color.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated RGB color.

Examples:

Shows color.hwb when optional params are omitted.

color.hwb()

Returns: [150,0.72,0]

Shows color.hwb using format.

color.hwb(format="decimal")

Returns: [150,0.72,0]

color.lab

Returns a LAB (CIELAB) color.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated RGB color.

Examples:

Shows color.lab when optional params are omitted.

color.lab()

Returns: [0.417022,44.0649,-99.9772]

Shows color.lab using format.

color.lab(format="decimal")

Returns: [0.417022,44.0649,-99.9772]

color.lch

Returns an LCH color.

ArgTypeRequiredDescription
formatdecimal|css|binarynoFormat of generated RGB color.

Examples:

Shows color.lch when optional params are omitted.

color.lch()

Returns: [0.417022,165.7,0]

Shows color.lch using format.

color.lch(format="decimal")

Returns: [0.417022,165.7,0]

color.rgb

Returns an RGB color.

ArgTypeRequiredDescription
casinglower|upper|mixednoLetter type case of the generated hex color. Only applied when 'hex' format is used.
formathex|decimal|css|binarynoFormat of generated RGB color.
includeAlphabooleannoAdds an alpha value to the color (RGBA).
prefixstringnoPrefix of the generated hex color. Only applied when 'hex' format is used.

Examples:

Shows color.rgb when optional params are omitted.

color.rgb()

Returns: #9f0632

Shows color.rgb using casing.

color.rgb(casing="upper")

Returns: #9F0632

Shows color.rgb using format.

color.rgb(format="hex")

Returns: #9f0632

Shows color.rgb using includeAlpha.

color.rgb(includeAlpha=true)

Returns: #9f063247

Shows color.rgb using prefix.

color.rgb(prefix="#")

Returns: #9f0632

color.space

Returns a random color space name from the worldwide accepted color spaces.

No parameters.

Examples:

Shows the default color.space call.

color.space

Returns: HSV