🌏 Translated with the assistance of DeepSeek and ChatGPT
Supported Color Formats for Parsing
Some components can receive and parse incoming color strings, which are then used to generate color swatches or for canvas drawing. The current component library supports parsing the following color formats.
| Format | Example | Description |
|---|---|---|
| Hexadecimal (HEX) | #f00#ff0000#ff0000ff#f00f | Supports 3, 4, 6, and 8-digit hexadecimal notation. |
rgb() / rgba() | rgb(255, 0, 0)rgba(255, 0, 0, 0.5)rgb(255, 0, 0, 0.5) | R, G, B components range from 0–255. Alpha value ranges from 0–1. |
hsl() / hsla() | hsl(0, 100%, 50%)hsla(0, 100%, 50%, 0.5)hsl(0, 100%, 50%, 0.5) | Hue: 0–359, Saturation and Lightness are percentages. Alpha value ranges from 0–1. |
hsv() / hsva() | hsv(0, 100%, 100%)hsva(0, 100%, 100%, 0.5)hsv(0, 100%, 100%, 0.5) | Hue: 0–359, Saturation and Value are percentages. Alpha value ranges from 0–1. |
hwb() / hwba() | hwb(0, 0%, 0%)hwba(0, 0%, 0%, 0.5)hwb(0, 0%, 0%, 0.5) | HWB color space. Hue: 0–359, Whiteness and Blackness are percentages. The sum of whiteness and blackness must not exceed 100%. Alpha value ranges from 0–1. |
Color parsing allows extra spaces.