DigitalService4Germany Style Dictionary
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 […]
-- Style Dictionary
Supported platforms
Currently the following platforms are supported. Please get in touch if you need support for another platform.
Installation
npm install @digitalService4Germany/style-dictionary
Usage examples
JavaScript/TypeScript
import { colorBackgroundButtonPrimaryFocus } from "@digitalService4Germany/style-dictionary";
console.log(colorBackgroundButtonPrimaryFocus);
Tailwind CSS
Style Dictionary provides a configuration preset which you can use as a base configuration. See Tailwind CSS docs for more information.
[…]
presets: [
require("@digitalservice4germany/style-dictionary/tailwind")
],
[…]
<div class="text-blue-900"></div> // #003350
Only a sensible subset of the tokens is available in Tailwind CSS.
Stitches
See Stitches docs for more information.
import stitchesConfig from "@digitalservice4germany/style-dictionary/stitches";
export const { css, … } = createStitches(stitchesConfig);
const button = css({
backgroundColor: "$blue900"
});
Only a sensible subset of the tokens is available in the Stitches configuration.
Development
npm link
Link the dist
directory, not the root directory.
npm run build
cp package.json dist/
cd dist
npm link
(inside dist
)
Release
npm run build
git status
(working directory needs to be clean)npm version patch
(or minor, major)npm push
npm push origin --tags
cd dist
(important: publish from dist directory!)npm publish