@zero-deps/hex-2-rgb
Version:
lightweight typed function to convert hexes of format #rrggbb to rgb(x,y,z) or rgba(x,y,z,a) without runtime dependencies
35 lines (21 loc) • 800 B
Markdown
> Zero dependencies 😍
Super lightweight typescript helper function to convert hexes of format `
This package is semantically released. For more information see [semantic-release](https://semantic-release.gitbook.io/semantic-release)
```
npm install @zero-deps/hex-2-rgb
```
```
import { hex2rgb } from '@zero-deps/hex-2-rgb'
const rgb = hex2rgb('#000000')
console.log(rgb) // rgba(0, 0, 0)
const rgba = hex2rgb('#FFFFFF', 0.5)
console.log(rgba) // rgba(255, 255, 255, 0.5)
```
**Smaller** than 170 bytes (commonjs, minified and gzipped).
**Smaller** than 120 bytes (EMS, minified and gzipped).
[](https://github.com/ai/size-limit) controls the size.