Skip to main content

Command Palette

Search for a command to run...

Today's npm package: color-alpha

Published
1 min read
Today's npm package: color-alpha
P

I am developer from India currently based in Berlin, Germany.

I am very interested in Design, though I don't design 😉 I take care of it while making my apps.

Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time 😊

Today's npm package is color-alpha

Color Alpha will let you customize the Alpha i.e. opacity of the colour in JS

Very useful in cases when → Adjusting minimal inline styles → Working with CSS-in-JS → Maintaining a Design System → Creating and Maintaining Style Guides → PostProcssing CSS Files

Here is how you can use it:

const A = require('color-alpha');

console.log(A('red', .35)) // "rgba(255,0,0,0.35)"
console.log(A('#f00', .35)) // "rgba(255,0,0,0.35)"
console.log(A('#ff0000', .35)) // "rgba(255,0,0,0.35)"
console.log(A('rgb(255, 0, 0)', .35)) // "rgba(255,0,0,0.35)"
console.log(A('rgba(255, 0, 0, 1)', .35)) // "rgba(255,0,0,0.35)"

See it in action here: https://runkit.com/pankaj/color-alpha

Stay tuned for tomorrow's package of the Day.

More from this blog

P

Pankaj Patel - @heypankaj_

63 posts

Sharing my learnings and thoughts on Blogging, Personal Branding and Programming