tuil
ReferencePackages

@mwillbanks/tuil-theme

Theme tokens, variants, utilities, capabilities, and registries for tuil.

View rawEdit

Overview

Theme tokens, variants, utilities, capabilities, and registries for tuil.

@mwillbanks/tuil-theme is independently installable and also participates in the umbrella @mwillbanks/tuil runtime where applicable.

Installation

npm install @mwillbanks/tuil-theme

How it operates

Themes normalize token sets, component defaults, slots, variants, terminal capabilities, and spacing. Registries resolve named themes while ThemeController provides live observable switching.

Documentation flow diagram. define; normalize; register; resolve; switch; unsubscribe; S0 leads to S1; S1 leads to S2
Documentation flow diagram. define; normalize; register; resolve; switch; unsubscribe; S0 leads to S1; S1 leads to S2

API

APISignatureDescription
ColorSchemetype ColorSchemePublic type ColorScheme.
compileUtilitiesfunction compileUtilitiesPublic function compileUtilities.
ComponentThemeinterface ComponentThemePublic interface ComponentTheme.
createDefaultThemeRegistryfunction createDefaultThemeRegistryPublic function createDefaultThemeRegistry.
createThemefunction createThemePublic function createTheme.
defaultLightThemeconstant defaultLightThemePublic constant defaultLightTheme.
defaultThemeconstant defaultThemePublic constant defaultTheme.
normalizeThemefunction normalizeThemePublic function normalizeTheme.
resolveComponentPropsfunction resolveComponentPropsPublic function resolveComponentProps.
resolveSlotPropsfunction resolveSlotPropsPublic function resolveSlotProps.
SemanticColorinterface SemanticColorPublic interface SemanticColor.
SlotComponentstype SlotComponentsPublic type SlotComponents.
SlotMaptype SlotMapPublic type SlotMap.
SlotPropFactorytype SlotPropFactoryPublic type SlotPropFactory.
SlotPropstype SlotPropsPublic type SlotProps.
SlottedComponentPropsinterface SlottedComponentPropsPublic interface SlottedComponentProps.
SpacingTokentype SpacingTokenPublic type SpacingToken.
TerminalStylePropstype TerminalStylePropsPublic type TerminalStyleProps.
Themeinterface ThemePublic interface Theme.
ThemeControllerclass ThemeControllerPublic class ThemeController.
ThemeFactorytype ThemeFactoryPublic type ThemeFactory.
ThemeInputtype ThemeInputPublic type ThemeInput.
ThemeProviderfunction ThemeProviderPublic function ThemeProvider.
ThemeRegistryclass ThemeRegistryPublic class ThemeRegistry.
ThemeRegistryEntryinterface ThemeRegistryEntryPublic interface ThemeRegistryEntry.
useThemefunction useThemePublic function useTheme.

Events and lifecycle

Theme changes use ThemeController.subscribe() so React consumers remain consistent with useSyncExternalStore.

All subscriptions and registrations return a disposer or belong to an owning runtime that disposes them in reverse order.

Example

import { createDefaultThemeRegistry } from "@mwillbanks/tuil-theme";

const themes = createDefaultThemeRegistry();
app.themeController.set(themes.resolve("default-light"));

On this page