@mocanvas/editor · function

registerColorsFromThemes

declare function registerColorsFromThemes(themes: TLThemes): void

Point the colour style props at the names the live themes actually define.

This is what lets an app ship a palette of its own: register a theme whose ramps carry extra names and color: "brand-teal" starts validating. It cuts both ways, which is the part worth being careful about — a name **no** registered ramp defines is *removed*, so a shape persisted with it no longer validates and the board it lives on will not load. A custom theme should therefore define every built-in name and change only their values; curate which names the UI *offers* in the UI, never by dropping them here.

The style props are module singletons, so this mutates their value list in place: the validator closes over that same array, and replacing the property would leave validation behind.

One caveat that belongs to records/styleProp.ts rather than to the theme system: DefaultColorStyle, DefaultLabelColorStyle and the exported DEFAULT_COLORS tuple are all the *same array* today, so registering a palette that adds or drops a name is visible through DEFAULT_COLORS too. Copying the list in the EnumStyleProp constructor would end that.

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.