npm.io
2.1.1 • Published 1 month ago

color-alpha

Licence
MIT
Version
2.1.1
Deps
1
Size
4 kB
Vulns
0
Weekly
0
Stars
23

color-alpha test size stable

Change alpha of a color.

$ npm install color-alpha

import α from 'color-alpha'
α('white', .4); // 'rgba(255,255,255, 0.4)'
α('oklch(0.628 0.258 29.234)', .3); // 'oklch(0.628 0.258 29.234 / 0.3)'
α('rgba(244, 244, 244, .3)'); // 'rgba(244,244,244, 0.3)' — no alpha reads the color's own

Input color is parsed with color-parse: legacy rgb/hsl keep comma syntax, modern spaces (lab, oklch, color(display-p3 …) etc.) serialize with css slash syntax. Unparseable input returns undefined.

Keywords