Open Props
@theme-kit/open-props
Expose Theme Kit semantic tokens as Open Props style variables for any design that uses CSS custom properties.
Installation
Install the adapter alongside @theme-kit/core (or a framework integration that provides the runtime).
pnpm add @theme-kit/open-propsPick your framework
The adapter is framework-agnostic — it's a hook, composable, directive or custom element depending on your stack. Pick yours to see the native API.
Quick Start
The snippet below uses the framework you picked — switch the picker above to see that framework's native API.
1import { ThemeProvider } from "@theme-kit/react";
2import { useOpenPropsTheme } from "@theme-kit/open-props";
3
4function Inside() {
5 useOpenPropsTheme();
6 return null;
7}
8
9export function App() {
10 return (
11 <ThemeProvider>
12 <Inside />
13 <YourApp />
14 </ThemeProvider>
15 );
16}Include the CSS
The adapter ships a stylesheet that maps its component variables (e.g. --primary for shadcn/ui, --bs-primary for Bootstrap) to the theme-kit --theme-color-* tokens. Import it once — anywhere — and the library's components will respond to every theme change automatically.
import "@theme-kit/open-props/open-props.css";What's Available
@theme-kit/open-props ships 6 exports in 2 categories. Click any export to reveal what it does and how to use it.
Adapter
Options
Use Cases
The important features in practice — copy any of these straight into your app.
Mount the adapter on the runtime
Register the Open Props adapter on an existing runtime.
import { createThemeRuntime } from "@theme-kit/core";
import { createOpenPropsAdapter } from "@theme-kit/open-props";
const runtime = createThemeRuntime();
runtime.adapters.use(createOpenPropsAdapter());Reference Open Props variables in CSS
Use `--op-*` tokens that update as the theme changes.
.banner {
background: var(--op-primary);
color: var(--op-on-primary);
border-radius: var(--op-radius-md);
}More Examples
Static variable maps for build-time CSS, and manual adapter lifecycle control.
import { createOpenPropsVariables } from "@theme-kit/open-props";
const css = createOpenPropsVariables({ family: "cocoa" });
// css: "--op-primary", "--op-background", "--op-radius-md", ...API Reference
Adapter
| Export | Description |
|---|---|
createOpenPropsAdapter(options) | Installs a tagged `:root` style element with concrete `--op-*` variables updated as the theme changes. |
createOpenPropsVariables(source) | Builds the Open Props variable map from a theme definition or tokens. |
useOpenPropsTheme(options?) | React hook that installs the Open Props adapter onto the active runtime. |
injectOpenPropsCSS() | Idempotent, SSR-safe helper for injecting Open Props compatibility CSS. |
Options
| Export | Description |
|---|---|
CreateOpenPropsAdapterOptions | Accepts `strategy` to customize token→variable mapping. |
OpenPropsAdapterOptions | Options for Open Props variable derivation and defaults. |