Theme
/ API Reference / Color Manipulation
Theme
/ API Reference / Color Manipulation

invert

A small utility function that inverts a CSS color value by rotating the hue by 180 degrees and inverting the lightness.
It uses the hsl color model to do so.

The Gist

import { invert } from '@weser/theme'

const inverted = invert('red')
const invertedVariable = invert('var(--background)')

Parameters

ParameterTypeDescription
valuestringThe CSS color value to invert.

Returns

(string) A string that references a CSS color value with the hue rotated and lightness inverted.

On this page