update_styles tool lets your agent modify the CSS properties of any component on the canvas by targeting it with its ID. You provide a map of CSS property names to values, and DesignJS applies them to the component in the GrapesJS style model. Changes appear immediately in the canvas and are persisted to .designjs.json on the next save.
The tool accepts standard CSS property names (e.g. "background-color", "font-size", "border-radius") as keys. Styles are merged into the component’s existing style map — any property you omit is preserved unchanged. Use CSS custom property references like var(--brand-primary) as values to tie component styles to your design tokens.
Parameters
string
required
The ID of the component to style. Obtain this from
get_tree, get_selection, or the componentIds returned by add_components.object
required
A
Record<string, string> mapping CSS property names to their new values. For example: { "background-color": "#4F46E5", "border-radius": "8px", "padding": "16px" }. Existing properties not included in this map are preserved unchanged.Response
object
required
The full updated styles map for the component after the changes have been applied. This reflects the complete set of CSS properties on the component, not just the ones you passed in.
Example
response
CSS custom properties defined on the canvas
:root (e.g. var(--brand-primary)) are valid values. The variable reference is stored as-written and resolved by the browser at render time. Use get_variables to see available custom properties.