Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hex-to-rgba

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hex-to-rgba

Converts hexadecimal color codes to rgb()/rgba() values.

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56K
increased by27.54%
Maintainers
1
Weekly downloads
 
Created
Source

'hex-to-rgba' turns an old-fashioned css hex color value string into a rgb() string.

If you specify an alpha value, you'll get a rgba() string instead.

Install

$ npm install --save hex-to-rgba

Usage

var hexToRgba = require("hex-to-rgba");

hexToRgba('112233', '0.5'); // "rgba(17, 34, 51, 0.5)"
hexToRgba('#112233', 0.75); // "rgba(17, 34, 51, 0.75)"
hexToRgba('#123', 0.2) // "rgba(17, 34, 51, 0.2)"
hexToRgba('112233'); // "rgb(17, 34, 51)"
hexToRgba('123'); // "rgb(17, 34, 51)"
hexToRgba('#123'); // "rgb(17, 34, 51)"

Parameters

hex: The hex value to convert. ('123456'. '#123456', ''123', '#123') a: An alpha value to apply. (optional) ('0.5', 0.25)

Returns

An rgb or rgba value. ('rgb(11, 22, 33)', 'rgba(11, 22, 33, 0.5)')

FAQs

Package last updated on 02 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc