Skip to main content

color

Macro color 

Source
color!() { /* proc-macro */ }
Expand description

Convert a color to a gpui::Hsla literal at compile time — the same conversion the ui! style tokens use, exposed standalone so theme palettes can be const. Accepts 3/4/6/8-digit hex (optional leading #, optionally quoted) or a named color.

ⓘ
use declarative_gpui::color;
use gpui::Hsla;

struct Theme { panel: Hsla, text: Hsla }
const DARK: Theme = Theme { panel: color!(1c1a17), text: color!("#f5f0e8") };

Storing theme tokens as Hsla (rather than hex u32s converted through rgb() per frame) makes a themed bg = (th.panel) a plain field copy — zero color math at render time.