color
background-color
Composes u.bg(), u.fg(), and u.border() so a surface's contrast holds by construction.
import { surface } from "@sdxc/u/color";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.surface() | css({ backgroundColor: "var(--ui-bg, Canvas)", color: "var(--ui-fg, CanvasText)", borderColor: "var(--ui-border, ...)" }) |
u.surface("brand.tinted") | css({ backgroundColor: "var(--ui-brand-bg-tint)", color: "var(--ui-brand-fg-emphasis)", borderColor: "var(--ui-brand-border)" }) |
u.surface("danger") | css({ backgroundColor: "var(--ui-danger-bg-solid)", color: "var(--ui-danger-fg-on-solid)", borderColor: "var(--ui-danger-bg-solid)" }) |
Using a custom value
Every scale argument also takes a raw CSS value, which passes through untouched.
u.surface()Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.surface())Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.surface())Customizing the theme
The custom properties this utility reads, which a theme redefines.
| Variable |
|---|
--ui-bg |
--ui-border |
--ui-brand-bg-tint |
--ui-brand-border |
--ui-brand-fg-emphasis |
--ui-danger-bg-solid |
--ui-danger-fg-on-solid |
--ui-fg |
Signature
u.surface(recipe?: SurfaceRecipe)