bricks_delete_global_variable
Overview
Permanently deletes a global CSS variable by ID. Any elements, global classes, or theme styles that reference this variable via var(--name) will lose their value and fall back to the browser default or inherited style.
This is a destructive operation. Before deleting, consider whether any part of the site relies on this variable. Use bricks_get_global_variables to verify the variable exists and confirm its name before deletion.
Key Features
When to Use
Cleaning up duplicate variables after a design system audit
Removing variables from a previous design that no longer applies
As part of a design system refactor when replacing old tokens with new ones
When NOT to Use
When the variable is actively referenced by elements — update those elements first
When you want to rename a variable — use bricks_update_global_variable which handles global rename
Parameters
variable_idstringREQUIREDCode Examples
Delete an Unused Variable
Remove an obsolete variable after confirming it is no longer referenced.
// Step 1: List variables and identify the one to delete
bricks_get_global_variables({})
// Find: { id: "v_old123", name: "old-spacing-xl", value: "40px" }
// Step 2: Delete it
bricks_delete_global_variable({
variable_id: "v_old123"
}){"success": true, "message": "Variable deleted successfully"}Common Mistakes
// Deleting without checking references
bricks_delete_global_variable({ variable_id: "v1a2b3" })
// Elements using var(--spacing-lg) now have no value!// First check for usage
bricks_search_content({ query: "var(--spacing-lg)" })
// If references exist, update them to use a different variable
// Then safely delete
bricks_delete_global_variable({ variable_id: "v1a2b3" })bricks_delete_global_variable({ variable_id: "spacing_md_id" })
// Now all elements using var(--spacing-md) break!// Update the value instead of deleting
bricks_update_global_variable({ variable_id: "spacing_md_id", value: "18px" })Tips & Warnings
Warning: Destructive operation. Deleted variables cannot be recovered. Any element using var(--deleted-name) will render with no value (browser default or inherited style).
Check references first: Use bricks_search_content to search for the variable name across all pages and templates before deleting.
Consider updating instead: If you want to change a variable, bricks_update_global_variable is safer than delete + recreate, as it preserves the ID and can rename references automatically.