Is Hexadecimal Dark Colour

Added in: @sardine/colour@1.2.0

Description

Checks if a given hexadecimal colour string represents a dark colour based on luminance.

Signature

function isHexDarkColour(hex: string): boolean;

Parameters

  • hex: string — The hexadecimal colour string (e.g., "#222429").

Returns

  • booleantrue if the colour is dark, otherwise false.

Examples

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

isHexDarkColour("#222429");
// => true

isHexDarkColour("#ffe000");
// => false

Error Handling

  • If the input is not a valid hexadecimal colour, the function may throw an error.

Interactive Demo

Try the function yourself with our interactive playground: