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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amsterdam/design-system-tokens

v0.13.0

Published

All design tokens from the Amsterdam Design System. Use it to apply its visual design to your website or application.

Downloads

4,091

Readme

Amsterdam Design System: Tokens

This package provides all design tokens from the Amsterdam Design System. Use it to apply its visual design to your website or application. The tokens are exported in multiple formats, including CSS custom properties and JSON, making them compatible with most, if not all, technology stacks.

Introduction

Every design token is a variable representing a single visual design choice. Tokens exist for colours, various aspects of text, spacing lengths, border widths, the configuration of animations, and more. The value of every token is valid in CSS. All tokens together form a theme that encodes the entire branding of the City of Amsterdam.

Installation

Install this package by itself if you want or need to reference tokens directly in your stylesheets.

Note that our CSS components and React components provide more functionality and apply the tokens automatically. You should use those packages if your application uses React or if it allows you to apply our HTML classes.

npm install @amsterdam/design-system-tokens

Usage in CSS

Tokens are typically used as custom properties in CSS. Their name starts with a prefix of --ams-; that of a component token (see below) with the property that uses it, e.g. -font-size.

Main stylesheet

This package offers a main stylesheet containing all tokens. They are declared as global CSS variables through the :root selector.

import "@amsterdam/design-system-tokens/dist/index.css"

If that doesn’t work for your project, use index.theme.css instead, which uses an .ams-theme selector. Add that class to a root element of your application.

import "@amsterdam/design-system-tokens/dist/index.theme.css"
<body class="ams-theme">
  …
</body>

Compact mode

Our branding is rather spacious for websites. The main stylesheet implements this ‘spacious mode’ as the default. A compact stylesheet is available for applications that require less white space and smaller text.

Note that the compact stylesheet is not independent – it only contains overrides. Import it after the main stylesheet for the correct result.

import "@amsterdam/design-system-tokens/dist/index.css"
import "@amsterdam/design-system-tokens/dist/compact.css"

Three layers

The tokens are organised in three layers: brand, common and component.

Brand tokens

These express the corporate identity of the City of Amsterdam. They are our fundamental selection from all possible colours, text characteristics, spacing lengths, border widths, etc. Examples:

:root {
  --ams-color-primary-red: #ec0000;
  --ams-space-md: 1rem;
  --ams-proportion-wide: 4/3;
  --ams-border-width-lg: 0.1875rem;
}

Find the list of brand tokens on GitHub.

Common tokens

Related components share visual design characteristics. For example, all links have the same colour, and the borders of various form inputs are equally thick. Common tokens express these relations and streamline future changes.

Design system components use common tokens where possible. The same goes for custom components that you may create in your application.

<a class="my-link" href="#">…</a>
.my-input {
  color: var(--ams-link-appearance-color);
  text-underline-offset: var(--ams-link-appearance-text-underline-offset);
}

Find the list of common tokens on GitHub.

Component tokens

Every design system component defines a token for every property that expresses branding and uses it in its stylesheet.

Use these tokens when recreating an existing component to receive the correct values for them – now and in the future. Do not apply these tokens to other components – components must be independent.

<button class="my-button" type="button">Button label</button>
.my-button {
  font-family: var(--ams-button-font-family);
  background-color: var(--ams-button-primary-background-color);
}

Find the list of component tokens on GitHub.

Overriding tokens

This package allows the creation of a theme to reuse our components for a different brand. This is a key feature of NL Design System of which we are part.

However, websites and applications for the City of Amsterdam must follow the design system as closely as possible. We repeat: websites and applications for the City of Amsterdam must follow the design system as closely as possible.

At the same time, we are aware that adopting a design system can pose challenges in practice. If there is a good reason to (temporarily) adapt a component, do so by overriding the values of its appropriate tokens in a separate stylesheet. Note that redefining the value of a token is a much better approach than redeclaring styles, adding class names or even inline styles.

Usage in Sass

The tokens can be imported as Sass variables as well.

@import "@amsterdam/design-system-tokens/dist/index.scss"

Import the compact tokens if you need them. Sass will override spacious values automatically.

@import "@amsterdam/design-system-tokens/dist/compact.scss"

Usage in JavaScript

Import the JSON file to use the tokens in TypeScript or JavaScript. Here, tokens start their name with a prefix of ams.. Use ‘dot notation’ or square brackets to access the tokens.

import tokens from "@amsterdam/design-system-tokens/dist/index.json"

const buttonBackgroundColor = tokens.ams.color["primary-blue"]
const rowGap = tokens.ams.space.md

Import and merge the compact tokens if you need them. Then you can use the tokens in scripting or css-in-js libraries.

import spaciousTokens from "@amsterdam/design-system-tokens/dist/index.json"
import compactTokens from "@amsterdam/design-system-tokens/dist/compact.json"

const tokens = { ...spaciousTokens, ...compactTokens }

Usage in Figma

The tokens are used in our Figma Library as well.

Updating

We follow semantic versioning and publish a change log to guide you through updates. The tokens are a public API of the design system. Note that detecting changed or deleted tokens is still a manual process.

Support

Contact us if you have a question, find an issue, or want to contribute. Find ways to reach us on designsystem.amsterdam.