Skip to main content

darken

function

Darken a color by a percentage. Works in HSL space for perceptually uniform results.

function darken(color: string, amount: number): string

Import

import { darken } from '@modular/sdk/theme';

Notes

returns
The darkened color as hex or rgba string
throws
Error if the color format is invalid or amount is out of range
example
```ts darken('#ffffff', 50) // => '#808080' darken('#ff0000', 20) // => '#990000' ```