colourCss

Converts a colour attribute value such as blue or hex(0064FA) to a CSS colour, or returns fallback if it is not a colour.

@internote/canvas-sdkFunction
On this page
import { colourCss } from '@internote/canvas-sdk';

The one function nearly every mark wants: it takes the attribute value exactly as the document carries it and gives back something a fill or a stroke can hold. For a colour that may be mid-way through a !cue.to change, blendedColourCss blends the two.

#Signature

(value: unknown, fallback?: string): string

#Parameters

value
A colour attribute value.
fallback
The CSS to return when the value is not a colour.

#Example

<circle fill={colourCss(attrs.colour)} />

Declared in packages/canvas-sdk/src/paint/colour.ts:519.

Last updated