JSPM

@davealdon/hext

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q38350F
  • License MIT

Adds transparency to your hex color codes

Package Exports

  • @davealdon/hext
  • @davealdon/hext/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@davealdon/hext) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hext

NPM Version TypeScript Jest

Get hex colors with transparency based on opacity percentage. Wow! No more rgb mixed with hex!

Install

npm install @davealdon/hext or yarn add @davealdon/hext

Then pass your hex color (string), and the percentage (number):

import { hext } from '@davealdon/hext';

const hexColor = hext('#ff0000', 30);

console.log(hexColor); // #ff00004D

This will output the color with the transparency code tacked onto the end. It's pretty simple!

Additional API usage

There's are a couple more functions available to you that hext uses to output the whole color code:

function usage description
hext hext('#ff0000', 30) // #ff00004D Returns entire hex code with transparency
transparencyToHex transparencyToHex(30) // 4D Returns only the transparency code. Does not include hash
convertToSixDigitHex convertToSixDigitHex("ff0") // ffff00 Converts a shorthand hex code and returns the full 6 character code. Does not include hash