Skip to content

Theemo / @theemo/style-dictionary / matchesConstraints

Function: matchesConstraints() ​

ts
function matchesConstraints(token, constraints): boolean;

Defined in: filters/constraints.ts:43

When you want to filter for any constraints (free from platform constraints), you can make yourself a filter for that.

Parameters ​

ParameterTypeDescription
tokenTransformedTokenthe token in question
constraintsConstraintsthe constraints you want to check against

Returns ​

boolean

true when the token matches against the given constraints, otherwise false

Example ​

Usage:

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

export default {
  source: ['tokens/**/*.json'],
  platforms: {
    css: {
      files: [
        {
          format: 'css/variables',
          destination: 'raw-tokens.css',
          filter: (token) => matchesConstraints(token, {
            features: {
              'density': 'spacious'
            }
          })
        }
      ]
    }
  }
};