New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lmc-eu/spirit-design-tokens

Package Overview
Dependencies
Maintainers
0
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lmc-eu/spirit-design-tokens

Design tokens for Spirit Design System

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@lmc-eu/spirit-design-tokens

Design tokens for Spirit Design System.

⚠️ Spirit design tokens are managed with and generated by Supernova. DO NOT EDIT MANUALLY!

Table of Contents

  1. Available Design Tokens
    1. Global Tokens
    2. Theme Tokens
  2. Themes
  3. Install
  4. Basic Usage
    1. In Sass
    2. In JavaScript
  5. Rebranding Spirit
  6. FAQ
  7. License

Available Design Tokens

Technically, design tokens are split into two categories: Global tokens and Theme tokens. Global tokens are shared independently on themes, while the theme tokens are specific to a particular theme.

They are all managed in our Figma and exported to our Supernova workspace.

⚠️ All content in src is generated by Supernova and should not be edited manually.

The scss directory contains @tokens.scss linking all available tokens (including both global and theme tokens).

Global Tokens

The category consists of these groups:

  • 🖼 Borders
  • 🖌️ Gradients
  • ⚙️ Other
  • 🎱 Radii
  • 🏖️ Shadows
  • 📏️ Spacing
  • 🔡 Typography

These tokens are shared globally and independently on themes.

Theme Tokens

Currently, only tokens in the 🎨 Colors group are themeable.

Themes

You can find the list of the themes in the @themes file and in the scss/themes directory. Each theme has its own directory with the same set of design tokens, but with different values.

As of now, we support two light-mode color themes:

  • Light Default (listed first in @themes, i.e. the default theme)
  • Light on Brand

Both themes can be used anywhere on the same page and combined as needed.

Using Themes

The scss directory contains @themes.scss linking all available themes as Sass variables. From the technical point of view, the theming is based on CSS variables. However, this package does not provide the CSS variables directly at the moment. Instead, they are generated from the @themes file in the spirit-web package.

Install

🙋🏻‍♂️ Hold on! Do you already use spirit-web? Then you don't need to install this package because spirit-design-tokens is installed automatically as a dependency of spirit-web.

If you want to use just spirit-design-tokens alone in your project, run:

yarn add @lmc-eu/spirit-design-tokens

or

npm install --save @lmc-eu/spirit-design-tokens

Basic Usage

In Sass

Sass (with the SCSS syntax) is the primary language for styling Spirit components.

The best way to use the design tokens is to load their path in Sass:

sass --load-path=node_modules/@lmc-eu/spirit-design-tokens/scss my-styles.scss

Or integrate them into your build system:

Vite example:
// vite.config.js

// …
import { defineConfig } from 'vite';

export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        includePaths: [path.resolve(__dirname, 'node_modules/@lmc-eu/spirit-design-tokens/scss')],
      },
    },
  },
});
// …
Webpack example with sass-loader:
// webpack.config.js

// …
module: {
  rules: [
    {
      test: /\.scss$/,
      use: [
        'style-loader',
        'css-loader',
        {
          loader: 'sass-loader',
          options: {
            sassOptions: {
              includePaths: [
                path.resolve(__dirname, 'node_modules'),
                path.resolve(__dirname, 'node_modules/@lmc-eu/spirit-design-tokens/scss'),
              ],
            },
          },
        },
      ],
    },
  ];
}
// …
Using the sass-embedded Library

If you're using sass-embedded, you can specify the API as legacy, modern, or modern-compiler. More information can be found in sass documentation.

We recommend using the modern-compiler option. Please note that this change also requires updating includePaths to loadPaths.

Webpack and sass-embedded:
// webpack.config.js

// …
module: {
  rules: [
    {
      test: /\.scss$/,
      use: [
        'style-loader',
        'css-loader',
        {
          loader: 'sass-loader',
          options: {
            api: 'modern-compiler',
            sassOptions: {
              loadPaths: [
                path.resolve(__dirname, 'node_modules'),
                path.resolve(__dirname, 'node_modules/@lmc-eu/spirit-design-tokens/scss'),
              ],
            },
          },
        },
      ],
    },
  ];
}
// …

The spirit-web package or your own components can simply reach token values like this:

@use 'sass:map';
@use '@tokens' as tokens;

.MyComponentThatMightGoToSpiritInFuture {
  margin-bottom: tokens.$space-300;
  font-family: map.get(tokens.$body-medium-regular, mobile, font-family);
  color: tokens.$text-primary;
}

For your components you can also load the token files directly:

@use 'node_modules/@lmc-eu/spirit-design-tokens/scss/@tokens' as tokens;

In JavaScript

Additionally, the design tokens are also provided as a JavaScript object.

import * as SpiritDesignTokens from '@lmc-eu/spirit-design-tokens';

const desktopBreakpoint = SpiritDesignTokens.breakpoints.desktop;

The structure is the same as in Sass.

Rebranding Spirit

The system is designed to be easily rebranded. To do so, you need to provide your own design tokens and use @tokens and @themes files. Then forward your tokens to these files and set the correct load path for your project.

Your tokens should contain the same structure as the Spirit tokens. The simplest way to do this is to have the same structure in your Figma file and export it using Supernova. If that's not possible, you can copy our tokens and adjust their values to your needs. You can also add new tokens required by your design system.

FAQ

Why do I need to rename @tokens to tokens when @using?

Because @using the @tokens module without renaming would produce an error:

Error: Invalid Sass identifier "@tokens"
  ╷
1 │ @use '@tokens';
  │ ^^^^^^^^^^^^^^
Why is there the @ prefix?

We prefix the @tokens.scss file with @ to differentiate it from other Sass files in the directory.

In order for developers to know the file behaves differently than usual Sass partials, a @ prefix is added to mark this behavior both in filesystem and inside Sass files. As a result, it's clear why e.g. @use 'tools' refers to a local file and @use '@tokens' does not. However, it's only a naming convention, there is no special tooling or configuration for Sass partials starting with @.

Imported module needs to be renamed to be compatible with SCSS syntax when it's used later on. That's why @use '@tokens' as tokens.

Look at the following snippets and compare which one offers better comprehensibility.

Without @ prefix:

// _Button.scss

@use 'tools'; // Calls './_tools.scss'. You don't have to explain this to me.
@use 'tokens'; // Wait, this file doesn't exist… What's going on here? Is it
// an error?

With @ prefix:

// _Button.scss

@use 'tools'; // Calls './_tools.scss'.
@use '@tokens' as tokens; // OK, './_@tokens.scss' is not here, but the at-sign
// prefix suggests a special behavior. Maybe I'll learn more in the docs?
How do I derive design tokens for my own design system?

Creating a custom design system derived from Spirit? Great to hear that! 🎉

While it's perfectly OK to develop custom components that may not find their way back to Spirit, your design tokens need to include all Spirit design tokens anyway, so all Spirit components you are going to reuse work correctly with your brand.

Simply put, if you are going to build a design system based on Spirit:

  1. copy and paste all design tokens from here,
  2. alter their values to fit your needs,
  3. feel free to add anything necessary on top of that,
  4. use your design tokens in your code (and compile Spirit with them).

To make your Sass design tokens compatible with Spirit, don't forget to expose them via Sass load path.

Do I need themes? And if so, how many?

You need at least one theme to define the default values for your design tokens. If you want to support multiple themes, you can add more. The number of themes is up to you and your design system requirements.

But remember, each theme should contain the same set of tokens, just with different values. This way, you can switch between themes without changing your components.

License

See the LICENSE file for information.

FAQs

Package last updated on 21 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc