bricks_update_global_class

Phase 2IntermediateComplexity: 5/10
Update an existing global class settings (deep merge)

Overview

Updates an existing global CSS class by deep-merging new settings into the current ones. Only the provided keys are changed; all other settings remain untouched. You can rename the class, change its category, modify CSS styles, or replace selectors.

This is ideal for iterative refinement of classes after initial creation, such as tweaking hover colors, adjusting spacing, or adding responsive breakpoint overrides without losing existing settings.

Key Features

Deep Merge Settings
Only the provided keys are changed. If a class has 10 settings and you send 2, only those 2 are updated — the other 8 remain intact.
Class Renaming
Changing the name field renames the CSS selector site-wide. All elements referencing this class automatically use the new name.
Selector Replacement
The selectors array replaces ALL existing selectors (not deep-merged). Provide the complete set of selectors you want.

When to Use

To tweak a class property without replacing the entire settings object (deep merge)
To rename a class — the CSS selector is updated site-wide automatically
To move a class to a different category
To add or replace hover/focus/pseudo-element selectors on an existing class
When audit feedback suggests adjusting class styles (contrast, spacing, font-size)
Prerequisites
The class must already exist. Use bricks_get_global_classes to find the class_id. Call bricks_regenerate_assets after updating to recompile the CSS.

When NOT to Use

When the class does not exist yet — use bricks_create_global_class to create it first
When you want to completely replace all settings — still works, but be aware it deep-merges (to remove a key, set it to null)
When you need to update multiple classes at once — there is no batch update tool; call this individually per class

Parameters

5 Total Parameters1 Required4 Optional
class_idstringREQUIRED
ID of the global class to update. Get this from bricks_get_global_classes.
namestringoptional
New class name. Renames the CSS selector site-wide. Use kebab-case.
categorystringoptional
New category name for the class.
settingsobjectoptional
CSS settings to deep-merge. Only provided keys change; omitted keys are preserved. Same format as bricks_create_global_class.
selectorsarrayoptional
Replaces ALL selectors (hover, focus, pseudo-elements). Provide the complete selector array you want.

Code Examples

Update font-size and add hover selector

Deep-merges a new font-size into existing typography settings and replaces selectors with a hover color effect.

JSON
// Update font-size and add a hover color to an existing class
bricks_update_global_class({
  class_id: "abc123",
  settings: {
    "_typography": { "font-size": "18px" }
  },
  selectors: [
    {
      selector: "&:hover",
      settings: {
        "_typography": { "color": { "raw": "var(--bricks-color-primary)" } }
      }
    }
  ]
})
Response
{
  "id": "abc123",
  "name": "text-body",
  "message": "Global class 'text-body' updated successfully."
}

Rename class and change category

Renames a class from its old name to "btn-cta" and moves it to the "Buttons" category. The CSS selector updates site-wide.

JSON
// Rename a class and move it to a different category
bricks_update_global_class({
  class_id: "def456",
  name: "btn-cta",
  category: "Buttons"
})
Response
{
  "id": "def456",
  "name": "btn-cta",
  "message": "Global class 'btn-cta' updated successfully."
}

Common Mistakes

Assuming selectors are deep-merged like settings. They are replaced entirely.
When updating selectors, always provide the complete selector array including existing selectors you want to keep.
Wrong
// Trying to add :focus while keeping existing :hover
bricks_update_global_class({
  class_id: "abc123",
  selectors: [{ selector: "&:focus", settings: { ... } }]
})
// RESULT: :hover selector is LOST!
Correct
// Include both :hover AND :focus in the array
bricks_update_global_class({
  class_id: "abc123",
  selectors: [
    { selector: "&:hover", settings: { ... } },
    { selector: "&:focus", settings: { ... } }
  ]
})
Using the class name instead of class_id to identify the class.
The class_id is a hex identifier, not the class name. Get it from bricks_get_global_classes first.
Wrong
bricks_update_global_class({ class_id: "btn-primary", settings: { ... } })
Correct
// First: bricks_get_global_classes({ search: "btn-primary" })
// Returns: { id: "d4e5f6", name: "btn-primary" }
bricks_update_global_class({ class_id: "d4e5f6", settings: { ... } })

Tips & Warnings

Tips & Warnings

Deep merge behavior: Settings are deep-merged, meaning you only need to send the keys you want to change. For example, sending {"_typography": {"font-size": "18px"}} preserves existing color, font-weight, etc.

Important: Selectors are NOT deep-merged — they are fully replaced. Always include all selectors you want to keep when updating.

Remember: Call bricks_regenerate_assets after updating classes to recompile CSS.

Return Values

FieldTypeDescription
idstringID of the updated class.
namestringCurrent class name (possibly renamed).
messagestringSuccess confirmation message.

Related Tools

Technical Details

Tool ID
bricks_update_global_class
API Endpoint
/bricks-mcp/v1/design-system/classes/{class_id}
HTTP Method
PUT
Namespace
design-system
Source File
design-system/classes.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release with deep-merge settings, selector replacement, and class renaming.
20250101