Skip to content

Theemo / @theemo/style-dictionary / isComputedToken

Function: isComputedToken()

ts
function isComputedToken(token): boolean;

Defined in: filters/computed.ts:49

Checks whether a token contains a transform.

A computed token:

json
{
  "$value": {
    "value": "#ee00aa",
    "transforms": {
      "alpha": -10
    }
  },
  "$type": "color"
}

Parameters

ParameterTypeDescription
tokenTransformedTokenthe token in question

Returns

boolean

true when the token contains a transform, otherwise false

Example

Usage:

js
import StyleDictionary from 'style-dictionary';
import { isComputedToken } from '@theemo/style-dictionary';

export default {
  source: ['tokens/**/*.json'],
  platforms: {
    css: {
      files: [
        {
          format: 'css/variables',
          destination: 'computed-tokens.css',
          filter: isComputedToken
        }
      ]
    }
  }
};