Darkens a hex color by a given percentage.
The hex color string.
The percentage to darken (0-100).
A new hex color string.
// ES Moduleimport { darken } from '@bnidev/js-utils'// CommonJSconst { darken } = require('@bnidev/js-utils') Copy
// ES Moduleimport { darken } from '@bnidev/js-utils'// CommonJSconst { darken } = require('@bnidev/js-utils')
darken('#ff0000', 20) // '#cc0000'darken('#ffffff', 50) // '#808080' Copy
darken('#ff0000', 20) // '#cc0000'darken('#ffffff', 50) // '#808080'
Darkens a hex color by a given percentage.