A Style Dictionary is a system that allows you to define styles once, in a way for any platform or language to consume. A single place to create and edit your styles, and a single command exports these rules to all the places you need them […]
Currently the following platforms are supported. Please get in touch if you need support for another platform.
- JavaScript/TypeScript
- Tailwind CSS
- Stitches (CSS-in-JS)
npm install @digitalservice4germany/style-dictionary
import { colorBackgroundButtonPrimaryFocus } from "@digitalService4Germany/style-dictionary";
console.log(colorBackgroundButtonPrimaryFocus); // #003350
Style Dictionary provides a configuration preset which you can use as a base configuration. See Tailwind CSS docs for more information.
// tailwind.config.js
[…]
presets: [
require("@digitalservice4germany/style-dictionary/tailwind")
],
[…]
// use in html
<div class="text-blue-900"></div> // #003350
Only a sensible subset of the tokens is available in Tailwind CSS.
See Stitches docs for more information.
// stitches.config.js|ts
import stitchesConfig from "@digitalservice4germany/style-dictionary/stitches";
export const { css, … } = createStitches(stitchesConfig);
// use in code
const button = css({
backgroundColor: "$blue900"
});
Only a sensible subset of the tokens is available in the Stitches configuration.
Link the dist
directory, not the root directory.
npm run build
cp package.json dist/
cd dist
npm link
(insidedist
)
npm run build
git status
(working directory needs to be clean)npm version patch
(or minor, major)git push
git push origin --tags
cd dist
(important: publish from dist directory!)npm publish