Color Utilities
Color Utilities
Section titled “Color Utilities”Helper functions for working with colors and color formats.
getFormat
Section titled “getFormat”Detects the format of a color string.
getFormat(color: string): 'hex' | 'rgb' | 'hsl' | 'oklch' | nullType Guards
Section titled “Type Guards”Boolean functions to check color types and values:
isAlpha(value)- Check if value is a valid alpha channelisChroma(value)- Check if value is a valid chroma valueisHex(value)- Check if value is a valid hex colorisHsl(value)- Check if value is a valid HSL colorisHue(value)- Check if value is a valid hue valueisHuey(value)- Check if value is a Huey color objectisOklch(value)- Check if value is a valid OKLCH colorisPercentage(value)- Check if value is a valid percentageisRgb(value)- Check if value is a valid RGB color
Examples
Section titled “Examples”import { getFormat, isHex } from 'huey/utils'
const format = getFormat('#ff0000') // 'hex'const valid = isHex('#ff0000') // true