bricks_delete_global_class
Overview
Deletes a global CSS class from the Bricks design system. By default, the tool performs a safety check to see if the class is currently used on any pages and returns a warning with usage details. Use force=true to delete even when the class is in use.
Deleted classes are moved to a 30-day retention trash, providing a safety net against accidental deletion. Elements that referenced the deleted class will lose that styling until a replacement is assigned.
Key Features
When to Use
During design system cleanup when consolidating similar classes
When a class was created with the wrong name and you want to start fresh
After confirming no elements use the class (via bricks_get_class_usage)
When NOT to Use
When you want to rename a class — use bricks_update_global_class with the name parameter
When you are unsure about usage — call bricks_get_class_usage first to check
Parameters
class_idstringREQUIREDforcebooleanoptionalfalseCode Examples
Delete an unused class safely
Deletes a class that is no longer referenced by any elements. The default safety check passes.
// Safely delete an unused class
bricks_delete_global_class({
class_id: "abc123"
}){
"message": "Global class 'old-button' deleted successfully. Moved to 30-day trash."
}Force delete a class in use
First attempts a safe delete (returns warning), then force-deletes. Elements lose the class reference.
// Attempt to delete a class that is in use (safety check)
bricks_delete_global_class({
class_id: "def456"
})
// Returns warning — then force if intended:
bricks_delete_global_class({
class_id: "def456",
force: true
})// First call (no force):
{
"message": "Class 'btn-primary' is in use on 3 pages (12 elements). Set force=true to delete anyway.",
"usage": { "pages": 3, "elements": 12 }
}
// Second call (force=true):
{
"message": "Global class 'btn-primary' force-deleted. 12 elements on 3 pages lost this class reference."
}Common Mistakes
// Force delete without checking impact
bricks_delete_global_class({ class_id: "abc123", force: true })
// 50 elements just lost their styling!// Check usage first
bricks_get_class_usage({ class_id: "abc123" })
// Returns: 50 elements on 8 pages
// Create replacement, then update elements, then delete
bricks_create_global_class({ name: "btn-new", settings: { ... } })
// ... update elements via bricks_update_element ...
bricks_delete_global_class({ class_id: "abc123" })Tips & Warnings
Safety first: Always attempt deletion without force=true first. The tool will tell you exactly how many pages and elements are affected. Only use force=true after confirming the impact is acceptable.
30-day trash: Deleted classes are recoverable for 30 days, but elements that referenced them will lose styling immediately upon deletion.
Best practice: Before deleting a class, check if it should be renamed or updated instead (bricks_update_global_class). Deletion is usually only needed for duplicates or obsolete classes.