bricks_export_variables
Overview
Exports all global CSS variables from the Bricks site in either JSON or CSS format. The JSON format includes full metadata (IDs, names, values, categories) suitable for reimporting into another Bricks site. The CSS format generates a clean :root { --name: value; } stylesheet.
This is essential for design system portability — export your variables from a staging site and import them into production, or share design tokens across multiple Bricks projects.
Key Features
When to Use
Migrating design tokens from one Bricks site to another
Generating a CSS file for use outside of Bricks (e.g., custom themes or external apps)
Documenting the current variable set for design handoff
Creating a snapshot before a design system refactor
When NOT to Use
When you want to import variables — use bricks_import_variables
Parameters
formatstringoptionaljson Values: json, cssCode Examples
Export as JSON for Reimport
Export the full variable set with categories, ready to import into another Bricks site.
bricks_export_variables({ format: "json" }){"variables": [{"id": "v1", "name": "spacing-xs", "value": "4px", "category": "cat1"}, {"id": "v2", "name": "spacing-sm", "value": "8px", "category": "cat1"}], "categories": [{"id": "cat1", "name": "Spacing"}]}Export as CSS
Generate a clean CSS stylesheet with all variables as custom properties.
bricks_export_variables({ format: "css" })":root {n --spacing-xs: 4px;n --spacing-sm: 8px;n --spacing-md: 16px;n --spacing-lg: 24px;n}"Common Mistakes
// Export as CSS then try to reimport — categories are lost
const css = bricks_export_variables({ format: "css" })
bricks_import_variables({ css: css })// Export as JSON preserves categories and structure
const data = bricks_export_variables({ format: "json" })
bricks_import_variables({ variables: data.variables, categories: data.categories })Tips & Warnings
Use JSON for backups and migrations: The JSON format preserves category organization and is directly compatible with bricks_import_variables.
Use CSS for documentation: The CSS format is ideal for design handoff, embedding in external stylesheets, or documenting the design system for developers.
Export before refactoring: Always export your variables before making large-scale changes to the design system. This gives you a backup you can reimport if needed.