bricks_create_variables_batch
Overview
Creates multiple global CSS variables in a single API call, supporting up to 50 variables at once. This is the recommended tool for setting up the design system’s spacing scale, sizing tokens, and other multi-value token sets in Phase 2 of a website build.
Significantly faster and more efficient than calling bricks_create_global_variable repeatedly. Categories referenced by name are auto-created if they do not exist.
Key Features
When to Use
Creating a full set of sizing, border-radius, or shadow tokens in one operation
Bootstrapping a design system with multiple variable categories at once
Any time you need to create 3 or more variables — always prefer batch over individual calls
When NOT to Use
When updating existing variables — use bricks_update_global_variable instead
When importing variables from a JSON or CSS export — use bricks_import_variables
Parameters
variablesarrayREQUIREDvariables[].namestringREQUIREDvariables[].valuestringREQUIREDvariables[].categorystringoptionalCode Examples
Create Full Spacing Scale
Set up the mandatory spacing scale (xs through 5xl) in a single API call during Phase 2.
bricks_create_variables_batch({
variables: [
{ name: "spacing-xs", value: "4px", category: "Spacing" },
{ name: "spacing-sm", value: "8px", category: "Spacing" },
{ name: "spacing-md", value: "16px", category: "Spacing" },
{ name: "spacing-lg", value: "24px", category: "Spacing" },
{ name: "spacing-xl", value: "32px", category: "Spacing" },
{ name: "spacing-2xl", value: "48px", category: "Spacing" },
{ name: "spacing-3xl", value: "64px", category: "Spacing" },
{ name: "spacing-4xl", value: "96px", category: "Spacing" },
{ name: "spacing-5xl", value: "128px", category: "Spacing" }
]
}){"success": true, "data": {"created": 9, "variables": [{"id": "v1", "name": "spacing-xs", "value": "4px"}, {"id": "v2", "name": "spacing-sm", "value": "8px"}, ...]}}Create Mixed Design Tokens
Create variables across multiple categories in one call — spacing, borders, and shadows.
bricks_create_variables_batch({
variables: [
{ name: "spacing-md", value: "16px", category: "Spacing" },
{ name: "spacing-lg", value: "24px", category: "Spacing" },
{ name: "radius-sm", value: "6px", category: "Borders" },
{ name: "radius-md", value: "12px", category: "Borders" },
{ name: "radius-lg", value: "20px", category: "Borders" },
{ name: "shadow-sm", value: "0 1px 3px rgba(0,0,0,0.1)", category: "Shadows" },
{ name: "shadow-md", value: "0 4px 12px rgba(0,0,0,0.08)", category: "Shadows" }
]
}){"success": true, "data": {"created": 7, "variables": [...]}}Common Mistakes
// Phase 2: Only creating colors and classes, forgetting spacing
bricks_create_color({ name: "primary", value: "#4361ee" })
bricks_create_global_class({ name: "btn-primary", settings: {...} })
// No spacing variables created! All spacing will be hardcoded.// Phase 2: Start with spacing variables FIRST
bricks_create_variables_batch({
variables: [
{ name: "spacing-xs", value: "4px", category: "Spacing" },
{ name: "spacing-sm", value: "8px", category: "Spacing" },
{ name: "spacing-md", value: "16px", category: "Spacing" },
{ name: "spacing-lg", value: "24px", category: "Spacing" },
{ name: "spacing-xl", value: "32px", category: "Spacing" },
{ name: "spacing-2xl", value: "48px", category: "Spacing" },
{ name: "spacing-3xl", value: "64px", category: "Spacing" },
{ name: "spacing-4xl", value: "96px", category: "Spacing" },
{ name: "spacing-5xl", value: "128px", category: "Spacing" }
]
})
// THEN create colors and classes// 9 separate API calls (slow, wasteful)
bricks_create_global_variable({ name: "spacing-xs", value: "4px", category: "Spacing" })
bricks_create_global_variable({ name: "spacing-sm", value: "8px", category: "Spacing" })
// ... 7 more individual calls// 1 API call for all 9 variables
bricks_create_variables_batch({ variables: [...all 9 spacing vars...] })// 60 variables in one call — will fail
bricks_create_variables_batch({ variables: [/* 60 items */] })// Split into two calls
bricks_create_variables_batch({ variables: [/* first 50 */] })
bricks_create_variables_batch({ variables: [/* remaining 10 */] })Tips & Warnings
This is the #1 recommended tool for Phase 2. The spacing scale (xs through 5xl) is mandatory for every site. Creating it in a single batch call is the most efficient approach.
Standard spacing scale: xs=4px (tight gaps), sm=8px (small gaps), md=16px (default), lg=24px (cards), xl=32px (section inner), 2xl=48px (content blocks), 3xl=64px (section padding), 4xl=96px (large sections), 5xl=128px (hero sections).
Category auto-creation: You do not need to call bricks_create_variable_category separately. Just include the category name in each variable object and categories are created on the fly.
Max 50 variables per call. For very large design systems, split into multiple batch calls.