Multi-tenant theming with modern CSS features
A comprehensive toolkit for multi-tenant SaaS theming with JSON tokens, modern CSS features, and powerful CLI tools. This toolkit provides everything you need to manage client-specific styles at scale while maintaining developer velocity and ensuring accessibility compliance.
- ๐จ Container Queries - Component-based responsive design with automatic polyfills
- ๐ญ CSS Layers (@layer) - Better cascade control and style organization
- ๐ Logical Properties - Internationalization-ready spacing and positioning
- ๐ Modern Color Functions - OKLCH, color-mix(), and advanced color manipulation
- ๐ Feature Detection - Runtime browser capability detection with fallbacks
- ๐ฆ Polyfill Management - Automatic loading and configuration of polyfills
- ๐จ JSON-based theme tokens with inheritance support
- ๐ Schema validation with strict property and unit enforcement
- โฟ Accessibility validation with WCAG compliance checking
- ๐ ๏ธ Powerful CLI for building, validating, and linting themes
- ๐ฏ Runtime theme loading with zero dynamic injection
- ๐ Tailwind CSS integration via dynamic preset generation
- ๐ Performance optimized with prebuilt CSS files
- ๐ฑ Container Queries for component-based responsive design
- ๐ญ CSS Layers for better style organization and cascade control
- ๐ CSS Logical Properties for internationalization support
- ๐ Complete Storybook Addon with React components and TypeScript
- โก CLI Watch Mode with hot reload and debounced rebuilding
- ๐จ Pre-built Templates (minimal, corporate, healthcare, fintech, glassmorphism, dark-mode)
- Interactive Demo showcasing all modern capabilities
npm install @saas-theme/core @saas-theme/cli @saas-theme/storybook-addon- Use a pre-built template:
npx saas-theme init --tenant my-client --template corporate- Or initialize with custom settings:
npx saas-theme init --tenant my-client --brand-color "#007bff"- Create a theme file (
themes/my-client.json):
{
"$schema": "../schemas/theme.schema.json",
"metadata": {
"name": "My Client Theme",
"version": "2.0.0",
"tenant": "my-client"
},
"tokens": {
"colors": {
"primary": {
"50": "#eff6ff",
"100": "#dbeafe",
"500": "#007bff",
"900": "#1e3a8a"
},
"semantic": {
"success": "#10b981",
"warning": "#f59e0b",
"error": "#ef4444"
}
},
"typography": {
"fontFamily": {
"sans": ["Inter", "system-ui", "sans-serif"],
"mono": ["JetBrains Mono", "Consolas", "monospace"]
},
"fontSize": {
"xs": "0.75rem",
"sm": "0.875rem",
"base": "1rem",
"lg": "1.125rem",
"xl": "1.25rem",
"2xl": "1.5rem"
}
},
"spacing": {
"xs": "0.25rem",
"sm": "0.5rem",
"md": "1rem",
"lg": "1.5rem",
"xl": "2rem"
},
"modernFeatures": {
"containerQueries": true,
"cssLayers": true,
"logicalProperties": true,
"colorFunctions": true
}
}
}- Build with modern features:
npx saas-theme build --input ./themes --output ./dist/themes --modern- Start watch mode for development:
npx saas-theme watch --input ./themes --output ./dist/themes@saas-theme/core- Theme engine with modern CSS support@saas-theme/cli- Enhanced CLI with watch mode and templates@saas-theme/tailwind-preset- Tailwind CSS integration with modern features@saas-theme/storybook-addon- Complete React-based Storybook integration
themes/
โโโ base.json # Base theme with modern features
โโโ templates/ # Pre-built theme templates
โ โโโ minimal.json
โ โโโ corporate.json
โ โโโ healthcare.json
โ โโโ fintech.json
โ โโโ glassmorphism.json
โ โโโ dark-mode.json
โโโ client-a.json # Client A theme
โโโ client-b.json # Client B theme with modern CSS
dist/themes/
โโโ base.css # Generated CSS with modern features
โโโ client-a.css # Client A theme CSS
โโโ client-b.css # Modern CSS with Container Queries
examples/
โโโ modern-features-demo/ # Interactive demo showcase
โโโ vanilla-css/ # Basic implementation
โโโ tailwind-example/ # Tailwind integration
โโโ react-saas-ui/ # Complete React example
# Build with modern CSS features
saas-theme build --modern --container-queries --css-layers --logical-properties --color-functions
# Build with polyfills for unsupported browsers
saas-theme build --modern --polyfills --feature-detection
# Watch mode with hot reload
saas-theme watch --input ./themes --output ./dist# Detect browser support for modern CSS features
saas-theme modern --detect
# Build with specific modern features
saas-theme modern -i themes -o dist --container-queries --css-layers
# Build with all modern features and polyfills
saas-theme modern -i themes -o dist --container-queries --css-layers --logical-properties --color-functions --polyfills# Validate themes
saas-theme validate themes/*.json --wcag AA --strict
# Lint codebase for hardcoded styles
saas-theme lint --dir ./src --extensions js,jsx,ts,tsx
# Compare theme versions
saas-theme diff themes/old.json themes/new.json
# Initialize new theme project
saas-theme init --dir . --template basic --tenant my-client
# Preview themes in development server
saas-theme preview --port 3000 --dir ./themes/* Generated CSS with Container Queries */
.card {
container-type: inline-size;
container-name: card;
}
@container card (min-width: 400px) {
.card-content {
padding: var(--spacing-lg);
display: grid;
grid-template-columns: 1fr 1fr;
}
}/* Organized with CSS Layers */
@layer base, components, utilities;
@layer base {
:root {
--primary-500: #007bff;
--spacing-md: 1rem;
}
}
@layer components {
.button {
background: var(--primary-500);
padding: var(--spacing-md);
}
}/* Internationalization-ready */
.content {
margin-inline-start: var(--spacing-md);
padding-block: var(--spacing-sm);
border-inline-end: 1px solid var(--border-color);
}// .storybook/main.js
module.exports = {
addons: ["@saas-theme/storybook-addon"],
features: {
modernInlineRender: true,
},
};- Real-time Theme Switching - Live preview with instant updates
- Client Approval Workflow - Share themes and collect feedback
- Theme Validation - Built-in accessibility and design checks
- Export Functionality - Generate production-ready CSS
- Modern CSS Preview - Container Queries and CSS Layers support
// stories/Button.stories.js
export default {
title: "Components/Button",
component: Button,
parameters: {
themes: {
default: "corporate",
list: [
{ name: "corporate", value: "corporate" },
{ name: "healthcare", value: "healthcare" },
{ name: "fintech", value: "fintech" },
],
},
},
};import { loadTheme, switchTheme, enableModernFeatures } from "@saas-theme/core";
// Enable modern CSS features
enableModernFeatures({
containerQueries: true,
cssLayers: true,
logicalProperties: true,
});
// Load theme with modern features
await loadTheme("client-a", { modern: true });
// Switch themes dynamically
await switchTheme("client-b", { modern: true });import { ContainerQueryManager } from "@saas-theme/core";
const cqManager = new ContainerQueryManager();
// Register container queries
cqManager.register("card", {
small: "(max-width: 300px)",
medium: "(min-width: 301px) and (max-width: 600px)",
large: "(min-width: 601px)",
});
// Apply responsive styling
cqManager.applyStyles("card", {
small: { padding: "var(--spacing-sm)" },
medium: { padding: "var(--spacing-md)" },
large: { padding: "var(--spacing-lg)" },
});Experience all features in the comprehensive demo:
# Open the modern features demo
open examples/modern-features-demo/index.htmlThe demo showcases:
- Container Queries - Responsive components based on container size
- CSS Layers - Organized styling with proper cascade control
- Theme Switching - Real-time theme changes with smooth transitions
- Modern CSS Features - All latest CSS capabilities in action
import { ColorHarmonyGenerator } from "@saas-theme/core";
const harmonyGen = new ColorHarmonyGenerator();
// Generate complementary colors
const complementary = harmonyGen.generateComplementary("#007bff");
// Generate triadic harmony
const triadic = harmonyGen.generateTriadic("#007bff");
// Generate analogous colors
const analogous = harmonyGen.generateAnalogous("#007bff", 5);
// Generate monochromatic palette
const monochromatic = harmonyGen.generateMonochromatic("#007bff", 9);import { AccessibilityColorGenerator } from "@saas-theme/core";
const accessGen = new AccessibilityColorGenerator();
// Generate WCAG AAA compliant palette
const palette = await accessGen.generateAccessiblePalette("#007bff", {
wcagLevel: "AAA",
colorBlindnessSupport: true,
highContrast: true,
});
// Validate color combinations
const validation = await accessGen.validateColorCombination(
"#007bff", // foreground
"#ffffff", // background
{ wcagLevel: "AA", fontSize: "16px" }
);- Minimal - Clean, simple design with essential elements
- Corporate - Professional business theme with trust-building colors
- Healthcare - Calming, accessible theme optimized for medical applications
- Fintech - Secure, modern theme for financial services
- Glassmorphism - Modern glass-effect design with backdrop filters
- Dark Mode - Elegant dark theme with proper contrast ratios
# Initialize with template
saas-theme init --template healthcare --tenant medical-client
# Apply template to existing theme
saas-theme template apply --template glassmorphism --theme themes/client-a.json
# Customize template
saas-theme template customize --template corporate --primary-color "#e74c3c"import { PerformanceAnalyzer } from "@saas-theme/core";
const analyzer = new PerformanceAnalyzer();
// Analyze theme performance
const metrics = await analyzer.analyzeTheme("themes/client-a.json");
console.log(metrics);
// {
// cssSize: "45.2kb",
// gzippedSize: "12.1kb",
// variableCount: 156,
// buildTime: "234ms",
// optimizationSuggestions: [...]
// }// Enable performance monitoring
import { enablePerformanceMonitoring } from "@saas-theme/core";
enablePerformanceMonitoring({
trackThemeSwitching: true,
trackCSSLoading: true,
reportMetrics: true,
});{
"modernFeatures": {
"containerQueries": {
"enabled": true,
"polyfill": "auto"
},
"cssLayers": {
"enabled": true,
"layerOrder": ["base", "components", "utilities"]
},
"logicalProperties": {
"enabled": true,
"fallbacks": true
},
"colorFunctions": {
"enabled": true,
"oklch": true,
"colorMix": true
}
},
"performance": {
"monitoring": true,
"optimization": "aggressive",
"caching": true
}
}{
"accessibility": {
"wcagLevel": "AA",
"contrastRatios": {
"normal": 4.5,
"large": 3.0,
"enhanced": 7.0
},
"colorBlindness": {
"simulate": true,
"types": ["protanopia", "deuteranopia", "tritanopia"]
},
"validation": {
"enforceContrast": true,
"checkFocusIndicators": true,
"validateTouchTargets": true
}
}
}- Location:
examples/modern-features-demo/ - Features: Container Queries, CSS Layers, theme switching, interactive demo
- Run:
open examples/modern-features-demo/index.html
- Location:
examples/react-saas-ui/ - Features: Complete React app with modern theming
- Run:
cd examples/react-saas-ui && npm start
- Location:
examples/vanilla-css/ - Features: Basic HTML/CSS usage with multiple themes
- Run:
open examples/vanilla-css/index.html
- Location:
examples/tailwind-example/ - Features: Tailwind CSS with dynamic theme presets
- Run:
cd examples/tailwind-example && npm run dev
class ModernCSSGenerator {
generateContainerQueries(breakpoints: Breakpoints): string;
generateCSSLayers(layers: LayerDefinition[]): string;
generateLogicalProperties(properties: Properties): string;
generateModernColors(palette: ColorPalette): string;
}class ThemeBuilder {
// Existing methods
loadTheme(filePath: string): Promise<Theme>;
buildCSS(theme: ResolvedTheme, options: BuildOptions): Promise<string>;
// New modern methods
buildModernCSS(
theme: ResolvedTheme,
options: ModernBuildOptions
): Promise<string>;
generateContainerQueries(theme: ResolvedTheme): Promise<string>;
optimizeForPerformance(css: string): Promise<OptimizedCSS>;
validateModernFeatures(theme: Theme): Promise<ModernValidationResult>;
}- Update dependencies:
npm update @saas-theme/core @saas-theme/cli @saas-theme/storybook-addon- Enable modern features:
{
"modernFeatures": {
"containerQueries": true,
"cssLayers": true,
"logicalProperties": true
}
}- Update build commands:
# Old
saas-theme build
# New
saas-theme build --modern- Migrate themes:
saas-theme migrate --from 1.x --to 2.0 --themes ./themes/We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
npm test - Submit a pull request
git clone https://github.com/yourusername/saas-theme-toolkit.git
cd saas-theme-toolkit
npm install
npm run build
npm testMIT License - see LICENSE file for details.
- ๐ Documentation
- ๐ฎ Interactive Demo
- ๐ฌ Discord Community
- ๐ Issue Tracker
- ๐ง Email Support
- ๐ฅ Video Tutorials
Special thanks to:
- The CSS Working Group for modern CSS features
- The accessibility community for WCAG guidelines
- All contributors and beta testers
- The open-source community for inspiration and feedback
SaaS Theme Toolkit 2.0 - Powering the next generation of multi-tenant theming with modern CSS and developer-first tooling.