Framework-agnostic design token engine for React, Vue, Angular, Svelte & vanilla JS
Documentation β’ Examples β’ Report Bug β’ Request Feature
# React
npm install @tokiforge/core @tokiforge/react
# Vue
npm install @tokiforge/core @tokiforge/vue
# Angular
npm install @tokiforge/core @tokiforge/angular
# Svelte
npm install @tokiforge/core @tokiforge/svelte
# Vanilla JS / Any Framework
npm install @tokiforge/core
1. Define your tokens (tokens.json):
{
"color": {
"primary": { "value": "#7C3AED", "type": "color" },
"accent": { "value": "#06B6D4", "type": "color" },
"text": {
"primary": { "value": "#1F2937", "type": "color" },
"secondary": { "value": "#6B7280", "type": "color" }
}
},
"spacing": {
"sm": { "value": "8px", "type": "dimension" },
"md": { "value": "16px", "type": "dimension" },
"lg": { "value": "24px", "type": "dimension" }
},
"radius": {
"sm": { "value": "4px", "type": "dimension" },
"lg": { "value": "12px", "type": "dimension" }
}
}
2. Use in React:
import { ThemeProvider, useToken } from '@tokiforge/react';
import tokens from './tokens.json';
function App() {
return (
<ThemeProvider tokens={tokens} defaultTheme="light">
<Button />
</ThemeProvider>
);
}
function Button() {
const primaryColor = useToken('color.primary');
const spacing = useToken('spacing.md');
const radius = useToken('radius.lg');
return (
<button
style={{
backgroundColor: primaryColor,
padding: spacing,
borderRadius: radius,
}}
>
Click me
</button>
);
}
3. Switch themes at runtime:
import { useTheme } from '@tokiforge/react';
function ThemeSwitcher() {
const { setTheme, currentTheme } = useTheme();
return (
<button onClick={() => setTheme(currentTheme === 'light' ? 'dark' : 'light')}>
Switch to {currentTheme === 'light' ? 'dark' : 'light'} mode
</button>
);
}
π View full documentation β
| Feature | TokiForge | Others |
|---|---|---|
| Runtime theme switching | β | β οΈ Often requires rebuild |
| Framework-agnostic | β | β Usually framework-specific |
| TypeScript support | β | β οΈ Partial or manual |
| Bundle size | β <3KB | β Often larger |
| CSS custom properties | β | β οΈ JS-heavy runtime |
| Zero JS overhead (static mode) | β | β Always requires JS |
ββββββββββββββββββββββββββββββββ
β Design Tokens (JSON) β
β (colors, spacing, etc.) β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌββββββββββββββββ
β TokiForge Core Engine β
β - Token Parser/Validator β
β - Runtime CSS Generator β
β - Theme Manager β
βββββββββββββββ¬ββββββββββββββββ
β
βββββββββββββββΌββββββββββββββββ
β Framework Adapters β
β (React/Vue/Angular/Svelte) β
βββββββββββββββ¬ββββββββββββββββ
β
βββββββββββββββΌββββββββββββββββ
β Your Application β
β Using Design Tokens β
ββββββββββββββββββββββββββββββββ
import { ThemeProvider, useToken } from '@tokiforge/react';
function App() {
return (
<ThemeProvider tokens={tokens}>
<Component />
</ThemeProvider>
);
}
<script setup>
import { useToken } from '@tokiforge/vue';
const primaryColor = useToken('color.primary');
</script>
import { ThemeService } from '@tokiforge/angular';
constructor(private themeService: ThemeService) {
const primaryColor = this.themeService.getToken('color.primary');
}
<script>
import { useToken } from '@tokiforge/svelte';
const primaryColor = useToken('color.primary');
</script>
import { ThemeRuntime } from '@tokiforge/core';
const runtime = new ThemeRuntime(tokens);
const primaryColor = runtime.getToken('color.primary');
runtime.applyTheme('dark');
π View complete examples β
Install the CLI globally:
npm install -g tokiforge-cli
Commands:
# Initialize a new token file
tokiforge init
# Build tokens to CSS/SCSS/JS
tokiforge build
# Start development server with live preview
tokiforge dev
# Validate token schema
tokiforge lint
# Validate tokens for CI/CD
tokiforge validate [--strict] [--figma]
# Compare Figma β Code tokens
tokiforge figma:diff --token TOKEN --file-key KEY
# Generate token analytics
tokiforge analytics
Contributions are welcome! Here's how you can help:
See CONTRIBUTING.md for guidelines.
Quick start for contributors:
# Clone the repo
git clone https://github.com/TokiForge/tokiforge.git
cd tokiforge
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm test
TokiForge is a framework-agnostic design token and theming engine that enables runtime theme switching using CSS custom properties. It works with React, Vue, Svelte, Angular, and any other JavaScript framework.
TokiForge provides runtime theme switching capabilities that Style Dictionary doesn't offer. While Style Dictionary focuses on build-time token transformation, TokiForge adds a lightweight runtime engine (<3KB) for dynamic theme management.
Yes! TokiForge has built-in support for light/dark themes and can automatically generate dark themes from light theme tokens.
Yes, TokiForge is production-ready with support for React, Vue, Svelte, and Angular. It's optimized for performance with a <3KB gzipped runtime footprint.
Absolutely! TokiForge is written in TypeScript and provides full type safety for design tokens and theme configurations.
Yes, TokiForge is SSR-safe and works with Next.js, Remix, Angular SSR, and other SSR frameworks.
generate:types)migrate, watch)MIT License β free for personal and commercial use.
Built with π by the TokiForge Community.
Inspired by the intersection of design and code.
β If you find TokiForge useful, please consider giving it a star on GitHub! β
Made with β€οΈ by TokiForge Community