tokiforge Svelte Themes

Tokiforge

Open-source modern design token & theme engine. Runtime theme switching for React, Vue, Svelte, Angular, and any framework β€” <3 KB, type-safe, and framework-agnostic.

🌈 TokiForge

Framework-agnostic design token engine for React, Vue, Angular, Svelte & vanilla JS

Documentation β€’ Examples β€’ Report Bug β€’ Request Feature


✨ Features

  • πŸš€ Framework-agnostic - Works with React, Vue, Angular, Svelte, Next.js, Remix, Solid, Qwik, or vanilla JS
  • 🎨 Runtime theme switching - Change themes instantly without page reload
  • πŸ“¦ Lightweight - Less than 3KB gzipped
  • πŸ”’ Full TypeScript support - Type-safe tokens with autocomplete
  • πŸ› οΈ Powerful CLI - Initialize, build, validate, and analyze tokens
  • 🎯 CSS custom properties - Native browser support with smart fallbacks
  • πŸŒ“ Dark mode ready - Built-in light/dark theme support
  • πŸ”„ Token versioning - Track versions, deprecations, and migrations
  • 🎭 Component theming - Scoped themes for individual components
  • πŸ”Œ Plugin system - Extensible with custom exporters and validators
  • β™Ώ Accessibility - Built-in WCAG compliance checking and contrast analysis
  • πŸ“± Responsive tokens - Breakpoint and state-aware token variations
  • πŸ” Figma sync - Compare and sync tokens with Figma designs
  • βœ… CI/CD ready - Automated validation for PRs and pipelines
  • πŸ“Š Analytics - Token usage tracking and bundle impact analysis
  • πŸ“š Multi-team support - Versioned token registry for design systems
  • πŸ’» IDE support - Autocomplete and hover previews (VSCode ready)
  • 🎨 Tailwind integration - Generate Tailwind config from tokens

πŸš€ Quick Start

Installation

# 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

Basic Usage

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 β†’


🎯 Why TokiForge?

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

πŸ“¦ Packages

Package Description npm
@tokiforge/core Core engine (works with any framework)
@tokiforge/react React adapter with hooks
@tokiforge/vue Vue 3 composables
@tokiforge/angular Angular service with Signals
@tokiforge/svelte Svelte stores
tokiforge-cli CLI tool for token management

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      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       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎨 Framework Examples

React

import { ThemeProvider, useToken } from '@tokiforge/react';

function App() {
  return (
    <ThemeProvider tokens={tokens}>
      <Component />
    </ThemeProvider>
  );
}

Vue

<script setup>
import { useToken } from '@tokiforge/vue';

const primaryColor = useToken('color.primary');
</script>

Angular

import { ThemeService } from '@tokiforge/angular';

constructor(private themeService: ThemeService) {
  const primaryColor = this.themeService.getToken('color.primary');
}

Svelte

<script>
  import { useToken } from '@tokiforge/svelte';
  const primaryColor = useToken('color.primary');
</script>

Vanilla JS

import { ThemeRuntime } from '@tokiforge/core';

const runtime = new ThemeRuntime(tokens);
const primaryColor = runtime.getToken('color.primary');
runtime.applyTheme('dark');

πŸ‘‰ View complete examples β†’


πŸ› οΈ CLI Tool

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

πŸ“š Documentation


🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. ⭐ Star the project - It helps others discover TokiForge
  2. πŸ› Report bugs - Open an issue on GitHub
  3. πŸ’‘ Suggest features - Share your ideas
  4. πŸ”§ Submit PRs - Fix bugs or add features
  5. πŸ“– Improve docs - Help make documentation better

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

❓ FAQ

What is TokiForge?

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.

How does TokiForge compare to Style Dictionary?

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.

Does TokiForge support dark mode?

Yes! TokiForge has built-in support for light/dark themes and can automatically generate dark themes from light theme tokens.

Is TokiForge production-ready?

Yes, TokiForge is production-ready with support for React, Vue, Svelte, and Angular. It's optimized for performance with a <3KB gzipped runtime footprint.

Can I use TokiForge with TypeScript?

Absolutely! TokiForge is written in TypeScript and provides full type safety for design tokens and theme configurations.

Does TokiForge work with SSR?

Yes, TokiForge is SSR-safe and works with Next.js, Remix, Angular SSR, and other SSR frameworks.


πŸ—ΊοΈ Roadmap

βœ… Completed (v1.0.0)

  • Core engine + React adapter
  • Vue/Svelte/Angular adapters
  • CLI tooling
  • TypeScript support
  • Token versioning & deprecation
  • Component theming
  • Plugin system
  • Accessibility dashboard
  • Responsive & state-aware tokens
  • Figma sync & diff tool
  • CI/CD integration
  • Token analytics
  • Versioned token registry
  • IDE support (API ready)
  • Tailwind CSS integration

🚧 In Progress (v1.1.0+)

  • Enhanced semantic tokens & aliasing
  • Multi-platform exporters (iOS, Android, React Native)
  • Type generation CLI (generate:types)
  • Enhanced Tailwind plugin format
  • CLI enhancements (migrate, watch)
  • Zero-JS + SSR improvements
  • Enhanced Figma integration (Tokens Studio)

πŸ“‹ Planned

  • VS Code extension
  • Visual playground enhancements
  • CI/Visual regression integration
  • Enhanced usage analytics
  • Community plugin examples

πŸ“– View Full Roadmap β†’


πŸ“„ License

MIT License β€” free for personal and commercial use.


πŸ™ Acknowledgments

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

Top categories

Loading Svelte Themes