set_text_background
Add or update the rounded background box behind a TEXT layer (text.) in one call — sets the backdrop fill plus the box's padding, corner radius, and optional stroke. Pass only the fields you want to change. New text layers are already text_autofit "hug", so padding alone shrink-wraps the box to the text — ideal for caption / sticker chips; set_layer_text(text_autofit:"hug") is only needed when adding a box to an OLDER layer still on "wrap". THIS IS HOW YOU BUILD A BUTTON: a button / CTA / chip / tag / pill / labelled badge is ONE text layer with a native background, never a rounded-rect shape with a text layer parked on top — padding is what sizes the box around the label, so the two can't drift apart when the text or the scale changes and the user drags one layer instead of two. The one exception: the box is NOT painted on CURVED text (a straight box behind a bent line reads as broken), so an arc-shaped chip genuinely needs a shape behind it. Pass fill null to remove the box. Text layers only; for shapes/images/video use set_layer_fill.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fill | No | Box fill: '#rrggbb' (promoted to solid) or a Fill object: {type:"solid",color} / {type:"linear",stops:[{pos:0..1,color}],angle?} / {type:"radial",stops:[{pos:0..1,color}],cx?,cy?,radius?} / {type:"mask",layer_id,color}. null clears the box; omit to leave the current fill. | |
| padding | No | Uniform inset (canvas px) between the box edge and the text. 0 / omitted ⇒ no explicit padding. | |
| elementId | Yes | text.<id>. | |
| projectId | Yes | Opaque project id (a v4 UUID, from list_projects/create_project). Selects which existing project this call mutates. | |
| strokeColor | No | Box outline colour as #rrggbb. | |
| strokeWidth | No | Box outline width in px. 0 / omitted ⇒ no outline. | |
| cornerRadius | No | Corner radius of the box in px. 0 ⇒ square corners. | |
| clear_animation | No | Only meaningful when `fill` is given AND the layer's backdrop fill is animated. true = the new fill REPLACES the colour animation. Omitted / false = the call is refused rather than writing a fill the animation would hide. |