惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
人人都是产品经理
人人都是产品经理
美团技术团队
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
博客园 - 【当耐特】
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
量子位
罗磊的独立博客
月光博客
月光博客
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
博客园_首页
P
Proofpoint News Feed
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
腾讯CDC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Introducing salt-theme-gen: Generate a Complete Design Sy...
Hasan Sarwer · 2026-06-16 · via DEV Community

You have a design system problem if any of these sound familiar:

  • Your _variables.scss has 80 hardcoded colors, half of them unused
  • Dark mode is a second file someone maintains by hand (when they remember)
  • Changing the primary color means grepping through a dozen partials and hoping nothing was hardcoded elsewhere
  • The designer asked for "slightly more rounded corners" and you spent 45 minutes finding every border-radius value

salt-theme-gen is a zero-dependency TypeScript package that generates a complete design token set from a single call.

What you get

import { generateTheme } from 'salt-theme-gen';

const theme = generateTheme({
  preset:   'ocean',    // or any hex color: '#6366f1'
  spacing:  'default',
  radius:   'default',
  fontSize: 'default',
});

One call. That's it. What comes back:

  • 21 semantic colorsprimary, secondary, background, surface, text, muted, border, danger, success, warning, info, and their on-colors
  • 32 interaction stateshover, pressed, focused, disabled for all 8 intents
  • 4 surface elevationsbase, raised, card, overlay
  • 6 spacing values — xs through xxl
  • 7 border-radius values — sm through pill
  • 7 font sizes — xs through 3xl
  • 18 WCAG accessibility checks — built-in, no extra library

All in light and dark mode. Both derived automatically.

Why OKLCH instead of hex

Most design token libraries give you hex or HSL values. salt-theme-gen uses OKLCH — the perceptually uniform color space that ships in all modern browsers.

What this means for you: when salt-theme-gen adjusts lightness for dark mode or derives a hover state, the perceived brightness change is consistent. oklch(0.55 0.2 240) lightened to oklch(0.65 0.2 240) looks the same magnitude of change regardless of hue. In HSL, the same numeric change can look wildly different across colors.

The result: dark mode colors that actually look right, not just mathematically derived.

Three steps to use it anywhere

Step 1 — Generate the theme:

const theme = generateTheme({ preset: 'ocean' });

Step 2 — Convert to CSS custom properties:

function modeToVars(mode) {
  const lines = [];
  const kebab = s => s.replace(/([A-Z])/g, '-$1').toLowerCase();

  for (const [k, v] of Object.entries(mode.colors))
    lines.push(`  --color-${kebab(k)}: ${v};`);
  for (const [k, v] of Object.entries(mode.spacing))
    lines.push(`  --space-${k}: ${v}px;`);
  for (const [k, v] of Object.entries(mode.radius))
    lines.push(`  --radius-${k}: ${v}px;`);
  for (const [k, v] of Object.entries(mode.fontSizes))
    lines.push(`  --text-${k}: ${v}px;`);

  return lines.join('\n');
}

const css = `
:root { ${modeToVars(theme.light)} }
:root[data-theme="dark"] { ${modeToVars(theme.dark)} }
`;

Step 3 — Inject into <head> and use in CSS:

.btn-primary {
  background: var(--color-primary);
  color:      var(--color-on-primary);
  padding:    var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
}

That's the whole pattern. Works in React, Next.js, Vue, Svelte, Angular, Astro, vanilla JS — anything that can put a <style> tag in <head>.

20 built-in presets

You don't need to pick colors — you pick a character:

Preset Character
ocean Deep blue, calm, professional
rose Warm, approachable, consumer
violet Creative, bold
emerald Fresh, growth
amber Energetic, warm
slate Neutral, minimal
midnight Dark-first, developer

...plus 13 more: ruby, cobalt, forest, sunset, arctic, copper, coral, sage, indigo, teal, gold, plum, crimson.

Or skip presets entirely and pass any hex:

generateTheme({ preset: '#6366f1' }) // your brand color

Scale presets

Three options each for spacing, radius, and font size:

generateTheme({
  preset:   'ocean',
  spacing:  'compact',  // or 'default' | 'spacious'
  radius:   'rounded',  // or 'sharp' | 'default' | 'pill'
  fontSize: 'large',    // or 'compact' | 'default'
});

A startup UI uses spacing: 'spacious' + radius: 'rounded'. A developer tool uses spacing: 'compact' + radius: 'sharp'. The personality of your UI comes from this combination, not just the color.

What's next in this series

This series covers every major framework and use case:

  • Dark mode with zero JavaScript flash (next article)
  • WCAG accessibility built-in — what the 18 checks cover
  • React, Next.js, Vue, SvelteKit, Angular, Astro, Remix — one article per framework
  • Tailwind CSS, React Native, Expo, Flutter, Storybook, CSS-in-JS, Sass
  • TypeScript integration — typed theme objects, exhaustive switches
  • Using with Claude Code, Cursor, and v0.dev — prompt templates

Install and follow along:

npm install salt-theme-gen

Full documentation: learn.esalt.net/salt-theme-gen


Part of the **salt-theme-gen — Design Tokens for Every Framework* series · Article 1 of 24*