Color - Play with Colors Convert, blend, manipulate and do more
API Reference for Color
The Color
class provides a robust way to work with colors in various formats (i.e. Hex, Hex8, RGB, HSL, RGBA, HSLA) and includes methods for color manipulation, blending, and accessibility checks.
Table of Contents
- Color Manipulation Methods
- Color Scheme Generation
- Accessibility & Contrast Methods
- Static Validation Methods
Type Definitions
Hex
type Hex = `#${string}`; // Format: #3C6945
Hex6
type Hex6 = Branded<`#${string}`, 'Hex6'>; // Format: #3C6945
Hex8
type Hex8 = Branded<`#${string}`, 'Hex8'>; // Format: #3C6945FF (with alpha)
RGB
type RGB = `rgb(${number}, ${number}, ${number})` | `rgb(${number},${number},${number})`; // Format: rgb(R, G, B)
RGBA
type RGBA = `rgba(${number}, ${number}, ${number}, ${number})` | `rgba(${number},${number},${number},${number})`; // With alpha
HSL
type HSL = `hsl(${number}, ${number}%, ${number}%)` | `hsl(${number},${number}%,${number}%)`; // Format: hsl(H, S%, L%)
HSLA
type HSLA = `hsla(${number}, ${number}%, ${number}%, ${number})` | `hsla(${number},${number}%,${number}%,${number})`; // With alpha
CSSColor
type CSSColor = keyof typeof CSS_COLORS; // All valid CSS color names
Percent
type Percent = 0 | 1 | 2 | ... | 100; // 0-100