Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@hueycolor/core

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hueycolor/core

Core utility lib for color manipulation for huey's components

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
203
38.1%
Maintainers
1
Weekly downloads
 
Created
Source

@hueycolor/core

Core color utilities powering @hueycolor/vue and @hueycolor/svelte. Can also be used standalone.

Installation

npm install @hueycolor/core

Usage

import { hueyColor } from '@hueycolor/core'

const color = hueyColor('#3b82f6')

color.toHslString()   // 'hsl(217, 91%, 60%)'
color.toRgbString()   // 'rgb(59, 130, 246)'
color.toHexString()   // '#3b82f6'
color.toOklchString() // 'oklch(62.80% 0.18 259.81)'

Accepts hex, rgb, hsl, and oklch strings.

API

hueyColor(input)

Creates a HueyColor instance from a color string or an existing HueyColor.

hueyColor('#ff0000')
hueyColor('rgb(255, 0, 0)')
hueyColor('hsl(0, 100%, 50%)')
hueyColor('oklch(62% 0.25 29)')

Conversion

MethodReturns
toHex()Hex string without #
toHexString()Hex string with #
toRgb(){ r, g, b, a }
toRgbString()'rgb(...)' / 'rgba(...)'
toHsl(){ h, s, l, a }
toHslString()'hsl(...)' / 'hsla(...)'
toOklchString()'oklch(...)'
toDisplayP3()'color(display-p3 ...)'
toRec2020()'color(rec2020 ...)'
toString()String in the original input format

Manipulation

All manipulation methods return a new HueyColor. The original is never mutated.

MethodDescription
setHue(h)Set hue (0–360)
setSaturation(s)Set saturation (0–100)
setLightness(l)Set lightness (0–100)
setAlpha(a)Set alpha (0–1)
lighten(amount)Increase lightness
darken(amount)Decrease lightness
brighten(amount)Increase brightness
saturate(amount)Increase saturation
desaturate(amount)Decrease saturation
randomize()Return a random color
clone()Return an identical copy

Inspection

MethodReturns
getAlpha()Alpha value (0–1)
getLuminance()Relative luminance (0–1)
getBrightness()OKLCH lightness (0–1)
isLight()true if lightness > 0.5
isDark()true if lightness ≤ 0.5
contrastRatio(other)WCAG contrast ratio
getFormat()Original input format: 'hex' | 'rgb' | 'hsl' | 'oklch'

License

MIT

Keywords

color

FAQs

Package last updated on 03 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts