bricks_update_global_variable
Overview
Updates an existing global CSS variable by ID. You can change the variable’s name, value, or category assignment. When renaming a variable, all references across the entire site are automatically updated — including pages, global classes, theme styles, and components.
This automatic global rename is one of the most powerful features of the variables system, as it ensures no references break when you refactor your design tokens.
Key Features
When to Use
Renaming a variable for better naming consistency (e.g., "gap-lg" to "spacing-lg")
Moving a variable to a different category for better organization
Refactoring design tokens across an established site
When NOT to Use
When you want to delete a variable — use bricks_delete_global_variable
When you need to update multiple variables — consider calling this tool once per variable
Parameters
variable_idstringREQUIREDnamestringoptionalvaluestringoptionalcategorystringoptionalCode Examples
Update a Spacing Value
Adjust the large spacing token from 24px to 28px across the entire site.
bricks_update_global_variable({
variable_id: "v1a2b3",
value: "28px"
}){"success": true, "data": {"id": "v1a2b3", "name": "spacing-lg", "value": "28px"}}Rename a Variable (Global Rename)
Rename a poorly-named variable. All references across pages, classes, and theme styles are updated automatically.
bricks_update_global_variable({
variable_id: "v1a2b3",
name: "spacing-lg"
})
// Previously named "gap-large" — all var(--gap-large) references become var(--spacing-lg){"success": true, "data": {"id": "v1a2b3", "name": "spacing-lg", "value": "24px", "references_updated": 47}}Move Variable to Different Category
Reorganize a variable from one category to another.
bricks_update_global_variable({
variable_id: "v4d5e6",
category: "Design Tokens"
}){"success": true, "data": {"id": "v4d5e6", "name": "color-accent", "value": "#c5a347", "category": "cat_design_tokens"}}Common Mistakes
bricks_update_global_variable({
variable_id: "spacing-lg",
value: "28px"
})// First get the ID
const vars = bricks_get_global_variables({})
// Find spacing-lg in the results, note its id: "v1a2b3"
bricks_update_global_variable({
variable_id: "v1a2b3",
value: "28px"
})// Creates a duplicate "spacing-lg"
bricks_create_global_variable({ name: "spacing-lg", value: "28px" })// Update the existing one
bricks_update_global_variable({ variable_id: "v1a2b3", value: "28px" })Tips & Warnings
Rename is powerful: When you rename a variable, the tool searches all pages, templates, global classes, theme styles, and components for var(--old-name) references and updates them to var(--new-name). This is a site-wide find-and-replace operation.
Value changes are instant: Since CSS variables cascade, changing a value here affects every element that references it. Test on a staging site first if making large-scale value changes.
No undo: Variable updates cannot be reverted automatically. Note the current value before changing it in case you need to roll back.