cssColor function
Any CSS colour as '#rrggbb', which three's `Color.setStyle` parses.
import { cssColor } from '@dioramajs/diorama/render'Alpha is dropped. Hex, rgb() and hsl() in both syntaxes and colour names are parsed here; other colour spaces go through a canvas, so they need a browser. Undefined for what is not a colour.
With element, var(--brand) (its fallback when unset, nested custom properties followed) and currentColor are read from the element's computed style, anywhere in the value, as in color-mix(in oklab, var(--brand), white). The value is read at the call: call again to see a changed variable.
function cssColor(value: string, element?: Element): string | undefinedParameters
| Name | Type | Description |
|---|---|---|
value | string | |
element? | Element |
Also exported from @dioramajs/render.
Defined in packages/render/src/color.ts.