Skip to main content

@rtorcato/js-common / colors

colors

Functions

randomColor()

randomColor(): string

Defined in: colors/index.ts:6

Generates a random hex color string.

Returns

string

A string representing a random color in hexadecimal format (e.g., #a1b2c3).


matchingTextColor()

matchingTextColor(color): "#000" | "#fff"

Defined in: colors/index.ts:20

Generates a random color with a given alpha value.

Parameters

color

string

Returns

"#000" | "#fff"

Export


hexToRgb()

hexToRgb(hex): { r: number; g: number; b: number; } | null

Defined in: colors/index.ts:36

Converts a hex color string to an RGB object.

Parameters

hex

string

Returns

{ r: number; g: number; b: number; } | null

{({ r: number; g: number; b: number } | null)}

Export


rgbToHex()

rgbToHex(r, g, b): string

Defined in: colors/index.ts:56

Converts RGB values to a hex color string.

Parameters

r

number

g

number

b

number

Returns

string

{string}

Export


isValidHex()

isValidHex(hex): boolean

Defined in: colors/index.ts:72

Converts a hex color string to an HSL object.

Parameters

hex

string

Returns

boolean

{({ h: number; s: number; l: number } | null)}

Export


darken()

darken(hex, percent): string

Defined in: colors/index.ts:84

Darkens a hex color by a given percentage.

Parameters

hex

string

percent

number

Returns

string

{string}

Export


lighten()

lighten(hex, percent): string

Defined in: colors/index.ts:101

Lightens a hex color by a given percentage.

Parameters

hex

string

percent

number

Returns

string

{string}

Export