Design System
/
Theming Runtime
Theming Runtime
Apply your tokens with <ThemeProvider> and consume them with typed hooks.
rastack/theme is the runtime side of the design system. <ThemeProvider tokens={…}> injects the CSS variables and manages light, dark, and custom modes.
1
import
{
ThemeProvider
,
useToken
,
useThemeMode
}
from
"rastack/theme"
;
2
import
{
theme
}
from
"@/tokens"
;
5
const
{
mode
,
setMode
}
=
useThemeMode
();
6
const
brand
=
useToken
(
"color.brand.500"
);
7
return
<
Button
color
={
brand
}
onPress
={()
=>
setMode
(
mode
===
"dark"
?
"light"
:
"dark"
)}
/>;
10
export
default
function
App
()
{
12
<
ThemeProvider
tokens
={
theme
}>
a token's var(--…) reference for a given TokenPath
the resolved concrete value
{ mode, setMode } for switching modes
the whole typed theme tree
› Good to know
Mode switches recascade via CSS variables with no re-render — exactly like RAStackProvider relocates the data engine without re-rendering your hooks.
Build with AI
Every page is available as clean Markdown for LLMs and coding agents. Point one at the files below to build on top of React API Stack.
React API Stack · alpha · built to scale to millions