Hex To RGBA
This HexToRgba
Helper Function is used to convert hex
value to rgba
.
HexToRgba
hextToRgba.ts
export const hexToRgba = (hex: string, alpha: number) => {
const r = parseInt(hex.slice(1, 3), 16)
const g = parseInt(hex.slice(3, 5), 16)
const b = parseInt(hex.slice(5, 7), 16)
return `rgb(${r}, ${g}, ${b}, ${alpha})`
}
Usage
card.tsx
const color = hexToRgba(colors.primary, 0.1)
Last updated on April 12, 2023