@mocanvas/editor · class

StyleProp

declare class StyleProp<T>

A shape prop that is a *style*: shared across shape types, remembered for the next created shape, and editable for a whole selection at once.


Methods · 5

protected constructor(id: string, defaultValue: T, validator?: ((value: unknown) => T) | undefined)
static define<T>(id: string, options: {

Define a style with a free-form value.

static defineEnum<const V extends readonly string[]>(id: string, options: {

Define a style whose value is one of a fixed set of strings.

isValid(value: unknown): boolean

Whether value is a legal value for this style. Present so that a style prop can stand in for a validator wherever a static props map is read.

validate(value: unknown): T

Properties · 2

readonly defaultValue: T
readonly id: string

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.