https://github.com/dominicegginton/hex-color-opacity
Lightweight module for adding opacity to hexadecimal colors
https://github.com/dominicegginton/hex-color-opacity
Last synced: 2 months ago
JSON representation
Lightweight module for adding opacity to hexadecimal colors
- Host: GitHub
- URL: https://github.com/dominicegginton/hex-color-opacity
- Owner: dominicegginton
- License: mit
- Created: 2020-11-17T00:56:19.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T16:08:54.000Z (10 months ago)
- Last Synced: 2025-03-18T04:12:32.576Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

## Install
``` shell
npm i hex-color-opacity
```## Usage
``` js
const opacity = require('hex-color-opacity')opacity('#FFFFFF', 0.5)
```## Documentation
### Adding opacity to hexadecimal color values
To add opacity to a hex color simply pass the color value (this includes the **#** character) and the desired opacity as a number value between 0 and 1 to the opacity function. The resulting hex value is returned. Support for 3 value hex colors is provided out of the box. All hex values are returned in upper case.
For example:
``` js
opacity('#FFF', 0.5) // #FFFFFF80
```## Contributing
Contributors are welcome, feel free to submit a new [pull request](https://github.com/dominicegginton/hex-color-opacity/pulls) to help improve **hex-color-opacity**.