Is CSS RGB Dark Colour

Added in: @sardine/colour@1.2.0

Description

Checks if a CSS RGB colour string represents a dark colour based on luminance.

Signature

function isCSSRGBDarkColour(cssRGB: string): boolean;

Parameters

  • cssRGB: string — The CSS RGB colour string (e.g., "rgb(34, 36, 41)").

Returns

  • booleantrue if the colour is dark, otherwise false.

Examples

import { isCSSRGBDarkColour } from "@sardine/colour";

isCSSRGBDarkColour("rgb(34, 36, 41)");
// => true

isCSSRGBDarkColour("rgb(255, 224, 0)");
// => false

Error Handling

  • Throws an error if the input is not a valid CSS RGB colour string.

Interactive Demo

Try the function yourself with our interactive playground: