https://github.com/ghostdevv/sass-hex-rgb
A util for converting hex values to rgb (e.g. #302def -> 48, 45, 239)
https://github.com/ghostdevv/sass-hex-rgb
hacktoberfest
Last synced: 11 months ago
JSON representation
A util for converting hex values to rgb (e.g. #302def -> 48, 45, 239)
- Host: GitHub
- URL: https://github.com/ghostdevv/sass-hex-rgb
- Owner: ghostdevv
- License: other
- Created: 2021-10-03T12:46:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T06:18:59.000Z (over 1 year ago)
- Last Synced: 2025-03-16T09:48:43.060Z (12 months ago)
- Topics: hacktoberfest
- Language: SCSS
- Homepage:
- Size: 119 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Sass Hex (to) RGB
> This package is compatible with both SASS and SCSS
A way to convert hex values to rgb in sass. The main reason this package exists is to get raw rgb values (e.g. 255, 255, 255) instead of a rgb value wrapped in a function. We also include functions to convert to rgb and rgba.
# Using
```scss
@use 'sass-hex-rgb' as rgb;
```
> Note: depending on how you resolve your sass imports you might need to import from the `node_modules` folder directly, e.g. `./node_modules/sass-hex-rgb`
# Functions
- `toValues($colour)`
```scss
$red: #f45333;
$redRGB: rgb.toValues($red); // "244, 83, 51"
```
- `toRGB($colour)`
```scss
$red: rgb.toRGB(#f45333);
```
- `toRGBA($colour)`
```scss
$redAlpha: rgb.toRGBA(#f45333, $alpha: 0.5); // rgba(244, 83, 51, 0.5);
```
> Note: I wanted to add `fromValues` as a function, but was unable to as the overhead of splitting the values and converting to a number is large. If anyone has a better idea please submit a [pr](https://github.com/ghostdevv/sass-hex-rgb/pulls)
# Support
- Join the [discord](https://discord.gg/2Vd4wAjJnm)
- Create a issue on the [github](https://github.com/ghostdevv/sass-hex-rgb)