themeOverrideStyle
themeOverrideStyle(overrides, overrideTypes) returns the public --todae-* custom properties ThemeProvider sets for its overrides, as a style object. It takes the same arguments as ThemeProvider's overrides and overrideTypes props and checks them the same way: an unknown key or a value of the wrong type throws in development and is left out in production.
On this page
themeOverrideStyle({ 'color.fg.default': { colorSpace: 'oklch', components: [0.2, 0, 0] } });
// { '--todae-color-fg-default': 'oklch(0.2 0 0)' }
The other helpers here work on one key or value, for a tool that edits overrides as text, such as a theme editor:
themeOverrideType(key)returns the$typeof one of Todae's override keys, such ascolorordimension.parseThemeValue(key, text)reads text as a value of the key's type, such as1.5remor200ms, and returnsnullfor text it does not read, such as16pxfor a dimension.parseThemeColor(text)reads a color such as#3366ccoroklch(0.5 0.1 30).themeValueCss(key, value)andthemeColorCss(value)write a value as CSS.cssVarName(path)returns the custom property for a token path, such as--todae-color-fg-defaultforcolor.fg.default.
When to use
When: A tool that builds or edits theme overrides, such as a theme editor, and reads, checks or shows them as CSS.
When not: Overrides for part of a page → ThemeProvider overrides. Values known at build time → a company token package.
Props
| Name | Type | Description |
|---|---|---|
overrides Required | ThemeOverride | Token paths and typed values, as ThemeProvider takes them. null or undefined gives {}. |
overrideTypes | ThemeOverrideTypes | Types for a company's own token paths, as ThemeProvider takes them. |
| Name | Type | Description |
|---|---|---|
key Required | ThemeOverrideKey | A key from THEME_OVERRIDE_KEYS. |
| Name | Type | Description |
|---|---|---|
key Required | ThemeOverrideKey | A key from THEME_OVERRIDE_KEYS. Its type decides how the text is read. |
text Required | string | The text to read. Spaces around it are ignored. |
| Name | Type | Description |
|---|---|---|
text Required | string | The text to read. Spaces around it are ignored. |
| Name | Type | Description |
|---|---|---|
key Required | ThemeOverrideKey | A key from THEME_OVERRIDE_KEYS. |
value Required | ThemeOverrideValue | A value of the key's type. |
| Name | Type | Description |
|---|---|---|
value Required | ThemeColorValue | An oklch color, as parseThemeColor returns. |
| Name | Type | Description |
|---|---|---|
path Required | string | A dotted token path. It is not checked against the token list. |