Skip to main content

Today's npm package: color-alpha

Updated 1 min readMarkdown
Part of seriesPackage of the Day
Today's npm package: color-alpha

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.

About the author

  • 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 😊

No comments yet. Be the first to comment.

More from this blog