← Back to Blog

Framework-Agnostic Theme System POC

Description

This proof-of-concept demonstrates a novel approach to theme generation that bridges the gap between design tokens and framework-specific implementations. The system dynamically generates themes for popular UI frameworks (DaisyUI, Material-UI, and Shadcn/UI) from a single source of truth - our design tokens package.

The POC addresses a common challenge in multi-framework environments: maintaining design consistency across different UI libraries while avoiding code duplication and manual synchronization.

Challenges

Solutions

Unified Token Loading System

Implemented a robust dynamic import strategy that gracefully falls back between package scope and relative paths:

export async function loadDesignTokens(brand: BrandName) {
  try {
    // Production: package scope
    return await import(`@codigo-obsidiana/design-tokens/${brand}`);
  } catch (error) {
    // Development: relative path fallback
    return await import(`../../../design-tokens/dist/${brand}/index.js`);
  }
}

Framework-Specific Generators

Created specialized generators that transform design tokens into framework-native formats:

Modular Architecture

Organized the codebase using the Single Responsibility Principle:

Tree-Shaking Strategy

Designed package exports to enable selective imports:

{
  "exports": {
    "./daisyui/*": "./dist/daisyui/*",
    "./mui/*": "./dist/mui/*",
    "./shadcn/*": "./dist/shadcn/*"
  }
}

Type-Safe Brand System

Implemented compile-time brand validation:

export type BrandName = 'ixiptla' | 'obsidiana';
export type ThemeMode = 'light' | 'dark';

Results

The POC successfully demonstrates:

Current Implementation Status

Next Steps for Production


This project showcases advanced TypeScript patterns, design system architecture, and framework-agnostic development approaches. The POC validates the feasibility of maintaining design consistency across multiple UI frameworks while providing excellent developer experience.