npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adddog/design-tokens

v0.0.2

Published

Configurable design token library built on Style Dictionary with CLI support for generating themes, colors, and design system tokens

Readme

@adddog/design-tokens

A configurable design token library built on Style Dictionary with CLI support for generating themes, colors, and design system tokens.

Features

  • 🎨 Dynamic theme generation from configuration files
  • 🔧 CLI tool for building and managing tokens
  • 🎯 Multiple output formats: CSS, SCSS, TypeScript, JSON
  • 🌗 Theme inheritance for easy variant creation
  • 👀 Watch mode for automatic rebuilds
  • Built-in validation for configuration
  • 📦 Programmatic API for advanced usage

Installation

npm install @adddog/design-tokens
# or
pnpm add @adddog/design-tokens
# or
yarn add @adddog/design-tokens

Quick Start

1. Initialize Configuration

npx design-tokens init

This creates a design-tokens.config.ts (or .js, .mjs) file in your project.

2. Define Your Themes

Edit the generated config file:

import { defineConfig } from '@adddog/design-tokens';

export default defineConfig({
  themes: [
    {
      name: 'light',
      colors: {
        primary0: '#ffffff',
        primary500: '#6E7076',
        primary950: '#000000',
        accent500: '#2C42D3',
        // ... more color tokens
      }
    },
    {
      name: 'dark',
      extends: 'light', // Inherit from light theme
      colors: {
        primary0: '#000000',
        primary950: '#ffffff',
        // Only override what's different
      }
    }
  ],
  output: {
    directory: './tokens',
    formats: ['css', 'scss', 'ts'],
    prefix: 'dt',
  },
});

3. Build Your Tokens

npx design-tokens build

This generates token files in your specified output directory:

  • tokens/light.css
  • tokens/dark.css
  • tokens/light.scss
  • tokens/dark.scss
  • etc.

4. Use Generated Tokens

In your CSS:

@import './tokens/light.css';

/* Tokens are available as CSS custom properties */
.button {
  background-color: var(--dt-color-accent500);
  color: var(--dt-color-primary950);
}

In your HTML:

<html class="light">
  <!-- Your app -->
</html>

Switch themes by changing the class:

<html class="dark">
  <!-- Now using dark theme -->
</html>

CLI Commands

design-tokens init

Create a starter configuration file.

npx design-tokens init [options]

Options:
  -f, --force    Overwrite existing config file

design-tokens build

Build design tokens from configuration.

npx design-tokens build [options]

Options:
  -c, --config <path>  Path to config file
  -w, --watch          Watch for changes and rebuild

design-tokens validate

Validate your configuration file.

npx design-tokens validate [options]

Options:
  -c, --config <path>  Path to config file

Configuration

Full Configuration Example

import { defineConfig } from '@adddog/design-tokens';

export default defineConfig({
  // Required: Define your themes
  themes: [
    {
      name: 'light',
      colors: {
        // Semantic color tokens
        primary0: '#ffffff',
        primary500: '#6E7076',
        primary950: '#000000',
        accent500: '#2C42D3',
        positive500: '#20C557',
        negative500: '#D63333',
        warning500: '#FFB800',
      }
    },
    {
      name: 'dark',
      extends: 'light', // Optional: inherit from another theme
      colors: {
        primary0: '#000000',
        primary950: '#ffffff',
      }
    }
  ],

  // Optional: Base colors shared across themes
  baseColors: {
    white: '#ffffff',
    black: '#000000',
    blue500: '#2C42D3',
    // Can reference in themes: { value: '{color.blue500}' }
  },

  // Optional: Sizing tokens
  sizing: {
    spacing0: { value: '0' },
    spacing1: { value: '4px' },
    spacing2: { value: '8px' },
    spacing4: { value: '16px' },
    spacing8: { value: '64px' },
  },

  // Optional: Font tokens
  font: {
    family: { value: 'system-ui, sans-serif' },
    sizeXs: { value: '12px' },
    sizeSm: { value: '14px' },
    sizeMd: { value: '16px' },
    sizeLg: { value: '18px' },
  },

  // Output configuration
  output: {
    directory: './tokens',       // Where to output files
    formats: ['css', 'scss', 'ts'], // Output formats
    prefix: 'dt',                 // CSS variable prefix
  },
});

Theme Inheritance

Themes can extend other themes to reduce duplication:

themes: [
  {
    name: 'base',
    colors: {
      primary500: '#6E7076',
      accent500: '#2C42D3',
    }
  },
  {
    name: 'light',
    extends: 'base',
    colors: {
      primary0: '#ffffff',
      primary950: '#000000',
    }
  },
  {
    name: 'dark',
    extends: 'base',
    colors: {
      primary0: '#000000',
      primary950: '#ffffff',
    }
  },
  {
    name: 'high-contrast',
    extends: 'dark',
    colors: {
      accent500: '#00FF00', // Override for accessibility
    }
  }
]

Programmatic API

You can also use the library programmatically:

import { buildTokens, loadConfig, resolveConfig } from '@adddog/design-tokens';

async function build() {
  const userConfig = await loadConfig('./my-tokens.config.ts');
  const config = resolveConfig(userConfig);
  const result = await buildTokens(config);

  if (result.success) {
    console.log('Generated:', result.generatedFiles);
  } else {
    console.error('Errors:', result.errors);
  }
}

Output Formats

CSS Variables

.light {
  --dt-color-primary0: #ffffff;
  --dt-color-primary500: #6E7076;
  --dt-color-accent500: #2C42D3;
}

SCSS Variables

$color-primary0: #ffffff;
$color-primary500: #6E7076;
$color-accent500: #2C42D3;

TypeScript

export const colorPrimary0 = "#ffffff";
export const colorPrimary500 = "#6E7076";
export const colorAccent500 = "#2C42D3";

Internal Monorepo Usage

This package is also used internally within the monorepo. The workflow is:

For Maintainers

  1. Edit the config: Modify design-tokens.config.ts in the package root
  2. Build: Run pnpm build to:
    • Build the library (CLI + API)
    • Generate internal tokens to output/
  3. Commit: The generated output/ files are committed to the repo

For Consumers (Other Monorepo Packages)

Import the pre-generated tokens directly:

import { DarkThemeTokens, LightThemeTokens } from '@adddog/design-tokens';
// or
import '@adddog/design-tokens/light.css';
import '@adddog/design-tokens/dark.css';

The internal build uses the same library API as external consumers, so everything stays in sync!

TypeScript Support

The package includes full TypeScript definitions. All configuration types are exported:

import type {
  UserConfig,
  ThemeDefinition,
  OutputConfig
} from '@adddog/design-tokens';

Scripts

| Script | Description | |--------|-------------| | build | Build library and generate internal tokens | | build:cli | Build CLI only | | lint | Lint codebase | | lint:fix | Fix linting issues | | types | Type check |

License

MIT

Contributing

This package is part of a monorepo. See the main repository README for contribution guidelines.