Skip to content

Configuration & Extension

Elevate offers a powerful and flexible configuration system that’s easy to adapt to your project’s design and architectural goals. However, with great power comes great responsibility—be sure to review each configuration option carefully to ensure it aligns with your project’s needs.

Basic Configuration

Elevate’s general settings are defined in elevate/config/elevate.ts:

elevate/config/elevate.ts
const options = {
Watch: './', // Directory to watch for changes
FileTypes: ['html', 'jsx', 'tsx', 'astro'], // File extensions to scan
Output: './' // Output directory for generated CSS
};
export const config = options;


Next up, you can import and distribute design system tokens in elevate/config/design.ts:

elevate/config/design.ts
// Design System Token Imports
// (includes both standard system tokens and custom tokens)
// Example: Utility import for additional spacing/height
import { heightUtility } from "../core/system/etc/height.js";
// Example: Custom values import
import { BrandColors } from "../design/example-brandTokens.js";
// System standard imports
import { colors } from "../core/system/design/colors.js";
import { spacing } from "../core/system/design/spacing.js";
import { typography } from "../core/system/design/typography.js";
import { breakpoints } from '../core/system/design/breakpoints.js';
// Token Definitions
export const designSystem = {
ColorToken: colors,
BreakPointToken: breakpoints,
SpacingToken: { ...spacing, ...heightUtility },
FontSizeToken: typography.size,
FontFamilyToken: typography.family,
LineHeightToken: typography.leading,
LetterSpacingToken: typography.tracking,
FontWeightToken: typography.weight,
// Spread in custom token categories
...BrandColors
};


Finally, syntax rule mappings are imported and distributed, and custom properties are defined, in elevate/config/syntax.ts:

elevate/config/syntax.ts
// Import Rule Files
import { Brand } from "../rules/example-brandRules.js";
// Spread Rules into Rules Object
export const rules = {
...Brand
};
// Define Custom Property and CSS Declaration Relationship
export const relationships = {
// Example Custom Property Definition
brand: {
"background-color": "BrandBackgroundRule",
"color": "BrandCopyRule"
}
};

Customization Tasks Cheat Sheet

In the majority of cases, you’ll only ever need to either:


A. Integrate Design System Tokens

  • Create token files in elevate/design.
  • Decide on whether you need to maintain compatibility with existing Elevate properties:
    • Yes: Spread your custom token objects into existing tokencategories in config/design.ts.
    • No: Create new token categories in config/design.ts and then see option ‘B’ below.

B. Expand Upon Elevate’s Syntax

  • Create new rule files in elevate/rules.
  • Import and spread these new rules into the rules object in config/syntax.ts.
  • Define new properties in the relationships object in config/syntax.ts, mapping tokens and rules to CSS declarations according to your needs.



Design System Integration

If your goal is to integrate your design system tokens into Elevate:



  1. Add new categorized design tokens to the elevate/design directory:
elevate/design/example-brandTokens.ts
export const BrandColors = {
BrandBackgroundTokens: {
'popgreen': '#39FF14'
},
BrandCopyTokens: {
'popwhite': '#FFFFFF'
}
};


  1. Import the new token categories into elevate/config/design.ts:
elevate/config/design.ts
import { BrandColors } from "../design/example-brandTokens.js";


  1. Spread the new token categories into the appropriate token definitions:
elevate/config/design.ts
// Token Definitions
export const designSystem = {
ColorToken: {
...colors,
...BrandColors.BrandBackgroundTokens,
...BrandColors.BrandCopyTokens
}
};


You can now reference these tokens in your utility strings as you would any of the existing Elevate tokens.



Extending Elevate’s Syntax

To create product-specific or project-specific syntax rules, follow these steps:


  1. Create a new file in the elevate/rules directory.
elevate/rules/example-brandRules.ts
export const Brand = {
BrandBackgroundRule: {
"bg-": "BrandBackgroundToken"
},
BrandCopyRule: {
"copy-": "BrandTextToken"
}
};




  1. Import the new rule file into elevate/config/syntax.ts and spread it in the rules object:
elevate/config/syntax.ts
import { Brand } from "../rules/example-brandRules.js";
export const rules = {
...Brand
};


  1. Define a new property in the relationships object and map your new modifier rules to the appropriate CSS declarations:
elevate/config/syntax.ts
export const relationships = {
brand: {
"background-color": "BrandBackgroundRule",
"color": "BrandCopyRule"
}
};


  1. Test your new property in an appropriate filetype (e.g. .html):
<div class="brand:bg-popgreen:copy-popwhite"></div>


Please note that Elevate includes a number of special token types that provide additional capabilities beyond the core functionality for specific situations.






Troubleshooting & Helpful Tips

Common Issues


  1. Token not mapping correctly?
    • Check if the design token is exported from its file.
    • Ensure the token is properly imported and spread in config/design.ts.
    • Confirm that any rules involving these tokens are correctly defined and imported in config/syntax.ts.

  1. Performance Considerations
    • Use rules for syntactic relationships, syntax expansion, or preventing token collisions.
    • Keep the number of tokens and rules minimal to limit complexity.

  1. Naming Conventions
    • Use clear, semantic names (e.g., BrandColorToken, TextAlignRule).
    • Avoid overly generic names that can cause collisions.
    • Prefix them to indicate their purpose, especially if you have many tokens.

Want To Go Deeper?

Elevate’s configurability makes it easy to integrate any design system or add custom features. Familiarize yourself with the existing rules in core/system to understand how Elevate maps tokens and rules to CSS declarations. Leverage this knowledge to create robust, maintainable utility-based styles that reflect your unique design system—while also ensuring maximum compatibility with Elevate’s defaults whenever possible.