Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

style-dictionary

Package Overview
Dependencies
Maintainers
3
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-dictionary

Style once, use everywhere. A build system for creating cross-platform styles.

  • 4.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
462K
increased by9.39%
Maintainers
3
Weekly downloads
 
Created

What is style-dictionary?

Style Dictionary is a build system that allows you to define styles once and use them everywhere. It helps in creating, maintaining, and distributing design tokens across different platforms and technologies.

What are style-dictionary's main functionalities?

Defining Design Tokens

You can define design tokens in a JSON file. These tokens can include colors, sizes, fonts, and other design-related properties.

{
  "color": {
    "background": {
      "base": {
        "value": "#ffffff"
      },
      "alt": {
        "value": "#f0f0f0"
      }
    }
  }
}

Transforming Tokens

You can transform tokens to different formats or units. For example, converting size values to pixels.

const StyleDictionary = require('style-dictionary');

StyleDictionary.registerTransform({
  name: 'size/px',
  type: 'value',
  matcher: function(prop) {
    return prop.attributes.category === 'size';
  },
  transformer: function(prop) {
    return parseFloat(prop.original.value) + 'px';
  }
});

Building Tokens

You can build tokens for different platforms like web, iOS, Android, etc. The build process can output tokens in various formats such as CSS variables, SCSS, JSON, etc.

const StyleDictionary = require('style-dictionary');

StyleDictionary.extend({
  source: ['tokens/**/*.json'],
  platforms: {
    web: {
      transformGroup: 'web',
      buildPath: 'build/web/',
      files: [{
        destination: 'variables.css',
        format: 'css/variables'
      }]
    }
  }
}).buildAllPlatforms();

Other packages similar to style-dictionary

Keywords

FAQs

Package last updated on 11 Nov 2024

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