filters.js
Custom token filters for Style Dictionary
On this page
filters.js
This script defines and registers custom filters for Style Dictionary. Filters control which tokens are included in each output file, based on type, path, or other properties.
Key Responsibilities
- Register custom filters for color, number, string, and theme tokens
- Exclude or include tokens based on type and path
- Enable fine-grained control over which tokens are output for each platform
Example Filters
cx/allTokens: Includes all tokens except certain excluded typescx/colorTokens: Includes only color tokens, excluding palette/context/utilitycx/themeTokens: Includes only theme color tokens, excluding base/utilitycx/numberTokens: Includes only number and certain size tokenscx/stringTokens: Includes only string tokens
Example Usage
import registerFilters from './filters.js'
registerFilters(StyleDictionary)