MotionScript

@motion-script/core


@motion-script/core / setTheme

Function: setTheme()

setTheme(theme?): void

Defined in: attributes/shape/fill/color/parser.ts:141

Registers a project theme: named colors (referenceable by name in any color string) and typography presets (selected via a Text/RichText variant).

Color entries take precedence over CSS named colors; nested color groups are flattened to dash-joined names ({ brand: { 500: … } }brand-500). Call with no argument (or an empty object) to clear both registries.

The default typography key is reserved: it's read directly by applyTextDefaults (not just via variant) and applied to every Text/RichText as a project-wide base style.

Parameters

theme?

ThemeInput = {}

Returns

void

Example

setTheme({
  colors: { brand: "#ff6b35", accent: { 500: "oklch(70% 0.2 145)" } },
  typography: {
    default: { fontFamily: "Inter", fontSize: 32 },
    header: { fontSize: 96, fontWeight: 700 },
  },
});
// Later: fill="brand", fill="accent-500", <Text variant="header" />