Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cobalt-ui/plugin-css

terrazzoapp3.5kMIT1.7.5TypeScript support: included

Generate CSS from your design tokens schema (requires @cobalt-ui/cli)

cobalt, design tokens, design tokens community group, design tokens format module, design system, dtcg, w3c design tokens, css

readme

@cobalt-ui/plugin-css

Generate CSS from your design tokens using Cobalt.

Features

  • ✅ 🌈 Automatic P3 color enhancement
  • ✅ Automatic mode inheritance (e.g. light/dark mode)

Basic Setup

Install the plugin from npm:

npm i -D @cobalt-ui/plugin-css

Then add to your tokens.config.mjs file:

// tokens.config.mjs
import pluginCSS from "@cobalt-ui/plugin-css";

/** @type {import("@cobalt-ui/core").Config} */
export default {
  tokens: "./tokens.json",
  outDir: "./tokens/",
  plugins: [pluginCSS()],
};

And run:

npx co build

You’ll then get a ./tokens/tokens.css file with CSS variables for you to use anywhere in your app:

/* tokens/tokens.css */

:root {
  --color-blue: #0969da;
  --color-green: #2da44e;
  --color-red: #cf222e;
  --color-black: #101010;
  --color-ui-text: var(--color-black);
}

Docs

View the full documentation

changelog

@cobalt-ui/plugin-css

1.7.5

Patch Changes

  • Fix issue with alias tokens and default name transformer (generates bad CSS)

1.7.4

Patch Changes

1.7.3

Patch Changes

1.7.2

Patch Changes

1.7.1

Patch Changes

1.7.0

Minor Changes

1.6.2

Patch Changes

  • #150 8c6893d Thanks @drwpow! - Bugfix: bugs in transform() API introduced in 1.6.0

  • #150 8c6893d Thanks @drwpow! - Bugfix: fix TypeScript signature for transform() plugin option

  • #150 8c6893d Thanks @drwpow! - Bugfix: mismatched versions of plugin-css and plugin-sass (if either were on latest) were broken.

1.6.1

Patch Changes

1.6.0

Minor Changes

1.5.1

Patch Changes

  • #132 97274f4 Thanks @drwpow! - Allow options?.transformer() to return undefined and fall back to default

1.5.0

Minor Changes

1.4.1

Patch Changes

1.4.0

Minor Changes

1.3.4

Patch Changes

1.3.3

Patch Changes

1.3.2

Patch Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

1.2.3

Patch Changes

1.2.2

Patch Changes

1.2.1

Patch Changes

1.2.0

Minor Changes

  • 526777f: Add fontFamily, fontWeight, fontName, and number types, remove font type

Patch Changes

1.1.6

Patch Changes

1.1.5

Patch Changes

1.1.4

Patch Changes

  • Update svgo to v3

1.1.3

Patch Changes

1.1.2

Patch Changes

  • 4eec0bd: Further improve aliases

1.1.1

Patch Changes

  • 3119292: Fix prefix bug

1.1.0

Minor Changes

  • 9edc9d9: Maintain aliases in CSS vars to improve mode support

Patch Changes

1.0.0

Minor Changes

  • e50c864: Add strokeStyle and border support in plugins, improve validation in core

Patch Changes

0.8.2

Patch Changes

0.8.1

Patch Changes

0.8.0

Minor Changes

  • 9e80004: Breaking change: improve and normalize transform API

Patch Changes

0.7.0

Minor Changes

  • a2a9d62: Changed typography tokens to generate multiple variables rather than classes

Patch Changes

  • ed21d56: Bump deps, add config type to docs
  • Updated dependencies [a2a9d62]
  • Updated dependencies [ed21d56]

0.6.0

Minor Changes

  • 07bc365: Update to Feb 2022 version of the Design Tokens format

0.5.2

Patch Changes

  • 35426a0: Fix P3 media query

0.5.1

Patch Changes

  • Update core

0.5.0

Minor Changes

  • 8845084: Add typography class support

0.4.3

Patch Changes

0.4.2

Patch Changes

  • 93668b9: Fix gradient generation

0.4.1

Patch Changes

  • f8f0e20: Fix unnecessary token duplication inside P3 query

0.4.0

Minor Changes

  • 19eb0ac: Add P3 support, (breaking) improve plugin options

Patch Changes

  • 8f5025d: Update package description

0.3.4

Patch Changes

  • Bump deps

0.3.3

Patch Changes

  • 4061584: Add autogenerated message to CSS & Sass

0.3.2

Patch Changes

  • 7883444: Fix font name quoting in typography type

0.3.1

Patch Changes

  • e935d23: Improve mode-selector

0.3.0

Minor Changes

  • 8d05fe8: Add Figma sync, make some breaking API changes

Patch Changes

0.2.1

Patch Changes

  • 6feabd5: Fix SVG embedding

0.2.0

Minor Changes

  • 26bfb4c: Convert to JSON, follow design tokens spec

Patch Changes

0.1.0

Minor Changes

  • 5748e72: Use JSON to align with the Design Tokens W3C spec