Skip to content

API Reference

@theme-kit/react

Provider, hooks and components for React 18/19 — the reference integration.

Functions

ThemeInspector(__namedParameters): Element

Returns Element


ThemeModeButton(): Element

Returns Element


ThemeProvider<T extends ThemeDefinition<string>>(__namedParameters): Element

Returns Element


ThemeScope(__namedParameters): Element

Returns Element


ThemeScrollbar(props): null

ThemeScrollbar — overlay only.

Creates the custom scrollbar overlay.

Lifecycle: mount → create overlay → measure → attach listeners paint → add tk-scrollbar-ready destroy → remove overlay

Props are organized into three optional groups — behavior, appearance and icons — but every option is also accepted as a flat, top-level prop (flat props win over the grouped ones).

<ThemeScrollbar behavior={{ autoHide: true, smooth: true }} appearance={{ thickness: 8, radius: 999 }} icons={{ up: <ArrowUpIcon />, down: <ArrowDownIcon /> }} />

ParameterTypeDescription
propsThemeScrollbarProps

Returns null


useScopedTheme(ref, selection, transition?): RefObject<{ destroy: void; getTheme: void; setLocalThemes: void; setTransition: void; update: void } | null>

ParameterTypeDescription
ref`RefObject<HTMLElementnull>`
selection`ScopedThemeSelectionnull`
transition`booleanThemeTransitionOptions` (optional)

Returns RefObject<{ destroy: void; getTheme: void; setLocalThemes: void; setTransition: void; update: void } | null>


useSetThemeFamily(): __type(nextFamily: string): void

Returns __type(nextFamily: string): void


useSetThemeMode(): __type(nextMode: ThemeMode): void

Returns __type(nextMode: ThemeMode): void


useTheme<T extends ThemeDefinition<string>>(): { family: string; mode: ThemeMode; setFamily: __type(nextFamily: string): void; setMode: __type(nextMode: ThemeMode): void; theme: T; toggleTheme: __type(): void }

Returns { family: string; mode: ThemeMode; setFamily: __type(nextFamily: string): void; setMode: __type(nextMode: ThemeMode): void; theme: T; toggleTheme: __type(): void }


useThemeBatch(): __type(callback: __type(): void): void

Returns __type(callback: __type(): void): void


useThemeFamily(): string

Returns string


useThemeHistory(): { canRedo: boolean; canUndo: boolean; clear: __type(): void; redo: __type(): void; undo: __type(): void }

Returns { canRedo: boolean; canUndo: boolean; clear: __type(): void; redo: __type(): void; undo: __type(): void }


useThemeLifecycle(): { on: __type(event: keyof ThemeLifecycleEventMap<ThemeDefinition<string>>, listener: __type(data: unknown): void): __type(): void }

Returns { on: __type(event: keyof ThemeLifecycleEventMap<ThemeDefinition<string>>, listener: __type(data: unknown): void): __type(): void }


useThemeMode(): ThemeMode

Returns ThemeMode


useThemePacks(): __type(pack: ThemePack<any>): void

Returns __type(pack: ThemePack<any>): void


useThemeRestore(): __type(snapshot: ThemeRuntimeSnapshot): void

Returns __type(snapshot: ThemeRuntimeSnapshot): void


useThemeRuntime<T extends ThemeDefinition<string>>(): ThemeRuntime<T>

Returns ThemeRuntime<T>


useThemeSchedule(): ThemeSchedule | null

Reactive access to the runtime's sunrise/sunset scheduling controller.

Requires the runtime to be created with the scheduled option (see ThemeProvider / createThemeRuntime). Returns null when the provider has no schedule configured.

tsx
const schedule = useThemeSchedule();
schedule?.enable();
schedule?.disable();
// schedule.enabled, schedule.active, schedule.sunrise, schedule.sunset,
// schedule.nextTransition ... re-render reactively.

Returns ThemeSchedule | null


useThemeSnapshot(): __type(): ThemeRuntimeSnapshot

Returns __type(): ThemeRuntimeSnapshot


useThemeTimeTravel(): { history: HistoryEntry<ThemeDefinition<string>>[]; jump: __type(index: number): void }

Returns { history: HistoryEntry<ThemeDefinition<string>>[]; jump: __type(index: number): void }


useThemeTokens<T extends ThemeDefinition<string>>(): ThemeTokens | undefined

Returns ThemeTokens | undefined


useThemeValue<T extends ThemeDefinition<string>>(): T

Returns T


useToggleTheme(): __type(): void

Returns __type(): void


Interfaces

ThemeInspectorProps

MemberTypeDescription
bottom (optional)numberVertical distance from the bottom of the viewport, in px. Default 104.
right (optional)numberHorizontal distance from the right edge of the viewport, in px. Default 32.
size (optional)numberToggle button size (width and height), in px. Default 40.
zIndex (optional)numberZ-index for the floating toggle and panel. Default 9999.

ThemeProviderProps<T extends ThemeDefinition>

Extends ThemeRuntimeOptions<T>

MemberTypeDescription
adapters (optional)ThemeAdapter<T>[]Library adapters installed when the runtime is created. The runtime owns
the registry and notifies every adapter whenever the theme changes; it
never knows anything about the libraries themselves.
broadcast (optional)`ThemeSelectionBroadcastAdapternull`
childrenReactNode
cssVariables (optional)`falseCSSVariablesOptions`
defaultTheme (optional)T["name"]
dom (optional)`falseDOMBindingOptions`
initial (optional)InitialThemeResolution<T>
initialFamily (optional)string
initialMode (optional)ThemeMode
persistence (optional)`ThemeSelectionPersistenceAdapternull`
plugins (optional)ThemePlugin<T>[]
readPersistenceOnInit (optional)boolean
runtime (optional)ThemeRuntime<T>
scheduled (optional)`falseScheduledThemeOptions<T>`
themes (optional)readonly T[]
transition (optional)`booleanThemeTransitionOptions`
view (optional)Window

ThemeScopeProps

MemberTypeDescription
childrenReactNode
className (optional)string
family (optional)stringTheme family for the scoped subtree. When mode is omitted the scope
follows the provider's current mode (light/dark/system).
mode (optional)ThemeModeMode for a family-based scope. Optional — defaults to the provider's
current mode so family="plum" flips light/dark with the page.
theme (optional)stringExact theme name, family name, or a { family, mode }-style object.
When family/mode are also passed, theme wins (it's the explicit
selection). Omit to follow the global selection inside a new boundary.
themes (optional)readonly ThemeDefinition<string>[]Local theme definitions for genuinely isolated components. Resolved FIRST
(they shadow same-named parent themes), then the provider's registry
falls back — no second runtime is created.
transition (optional)`booleanThemeTransitionOptions`
<ThemeProvider/> transition, false disables it, true inherits, and
an object is merged over the provider's config (local keys win).

ThemeScrollbarAppearance

Extends Pick<OverlayScrollbarOptions, "arrows" | "thickness" | "hoverThickness" | "radius" | "minThumbSize" | "offset" | "trackOpacity" | "thumbOpacity" | "zIndex" | "duration" | "animationDuration" | "thumbColor" | "trackColor" | "activeThumbColor" | "thumbHoverColor"> Appearance — the look/size of every strip.

MemberTypeDescription
activeThumbColor (optional)stringCustom thumb color while the user is dragging it. When set,
overrides the theme-derived active color. Default undefined
(uses thumbColor or theme-derived).
animationDuration (optional)numberrAF easing time constant (ms) for smooth thumb travel. Default 180.
arrows (optional)booleanShow the up/down (or left/right) navigation buttons like native browser
scrollbars. Clicking scrolls a step; holding repeats. Default true.
duration (optional)numberCSS transition duration (ms) for thickness/opacity/color. Default 250.
exclude (optional)`string[]null`
hoverThickness (optional)numberThumb thickness while hovered / dragged — only used when hoverExpand is true. Default thickness + 4.
include (optional)`string[]null`
minThumbSize (optional)numberMinimum thumb travel size. Default 32.
offset (optional)numberGap between the thumb and the container edge in px. Default 2.
radius (optional)numberThumb corner radius in px. Default 999.
thickness (optional)numberResting thumb thickness (width for vertical, height for horizontal). Default 8.
thumbColor (optional)stringCustom thumb color (any CSS color string). When set, overrides
the theme-derived color. Default undefined (theme-derived).
thumbHoverColor (optional)stringCustom thumb color while hovered. When set, overrides the
theme-derived hover color. Default undefined (uses thumbColor
or theme-derived).
thumbOpacity (optional)numberThumb opacity while visible. Default 0.7.
trackColor (optional)stringCustom track color (any CSS color string). When set, overrides
the theme-derived color. Default undefined (theme-derived).
trackOpacity (optional)numberTrack strip opacity (0 = invisible). Default 0.25.
zIndex (optional)numberZ-index for the overlay strips. Defaults to the tracked container's own
z-index (so the scrollbar stays inside its container's stacking order —
e.g. below a sticky header). The document scrollbar defaults to 55
(above typical sticky headers, below full-screen modal backdrops) and
containers without a z-index default to 30. Overriding lets you force
scrollbars above fixed headers/modals if you need to.

ThemeScrollbarBehavior

Extends Pick<OverlayScrollbarOptions, "autoHide" | "hoverExpand" | "draggable" | "clickToJump" | "smooth" | "overscroll" | "axes" | "touch" | "dir"> Behavior — how the overlay scrolls and hides.

MemberTypeDescription
autoHide (optional)booleanFade the thumb/track out while idle. Default true (macOS-style).
autoHideDelay (optional)numberIdle (ms) before a revealed strip fades out. Default 900.
axes (optional)ScrollbarAxis[]Which axes to render. Defaults to both.
clickToJump (optional)booleanClicking the empty track scrolls smoothly to that position. Default true.
dir (optional)`"ltr""rtl"
draggable (optional)booleanAllow dragging the thumb to scroll. Default true.
hoverExpand (optional)booleanGrow the strip on hover / drag. Default false (thickness stays
constant so the scrollbar never shifts while scrolling).
overscroll (optional)booleanSubtly compress the thumb at the scroll boundaries (rubber-band feel). Default true.
smooth (optional)booleanUse rAF-lerped (eased) thumb motion instead of a hard snap. Default true.
touch (optional)booleanNative (touch) devices: keep native scrollbars by default. Pass true to
force the overlay on coarse-pointer devices. Default false.

ThemeScrollbarIcons

Arrow button icons (any ReactNode — JSX, inline SVG, text, …).

MemberTypeDescription
arrow (optional)ReactNode
down (optional)ReactNode
left (optional)ReactNode
right (optional)ReactNode
up (optional)ReactNode

ThemeScrollbarProps

MemberTypeDescription
activeThumbColor (optional)string
animationDuration (optional)number
appearance (optional)ThemeScrollbarAppearanceGrouped appearance options. Flat props override these.
arrowDownIcon (optional)ReactNodeJSX / element for the "scroll down" button. Falls back to arrowIcon.
arrowIcon (optional)ReactNodeJSX / element rendered inside every arrow button (overrides the built-in
CSS triangle). Accepts any ReactNode.
arrowLeftIcon (optional)ReactNodeJSX / element for the "scroll left" button. Falls back to arrowIcon.
arrowRightIcon (optional)ReactNodeJSX / element for the "scroll right" button. Falls back to arrowIcon.
arrows (optional)boolean
arrowUpIcon (optional)ReactNodeJSX / element for the "scroll up" button. Falls back to arrowIcon.
autoHide (optional)booleanFlat aliases mirroring OverlayScrollbarOptions (for convenience /
backwards compatibility). Each is overridden by the matching flat prop.
autoHideDelay (optional)numberIdle (ms) before a revealed strip fades out after its last activity.
Each host has its own timer, so only the strip you're scrolling/hovering
is revealed, then it fades after idle; other scrollbars stay hidden.
Default 900. Only takes effect when autoHide is true.
axes (optional)ScrollbarAxis[]
behavior (optional)ThemeScrollbarBehaviorGrouped behavior options. Flat props (e.g. autoHide) override these.
children (optional)ReactNode
clickToJump (optional)boolean
dir (optional)`"ltr""rtl"
draggable (optional)boolean
duration (optional)number
exclude (optional)`string[]null`
hoverExpand (optional)boolean
hoverThickness (optional)number
icons (optional)ThemeScrollbarIconsGrouped arrow button icons. Flat arrow*Icon props override these.
include (optional)`string[]null`
minThumbSize (optional)number
offset (optional)number
overscroll (optional)boolean
radius (optional)number
smooth (optional)boolean
thickness (optional)number
thumbColor (optional)string
thumbHoverColor (optional)string
thumbOpacity (optional)number
touch (optional)boolean
trackColor (optional)string
trackOpacity (optional)number
zIndex (optional)number

@theme-kit/react — API Reference — Theme Kit