setAttributes

setAttributes

Set the attributes of the text style. All attributes except breakpoints are merged with existing values. When setting breakpoints, the provided array replaces any existing breakpoints entirely. To update breakpoints without overriding them all, iterate over the existing breakpoints and merge them.

// Update the color of a text style.
const textStyle = await framer.getTextStyle("text-style-id")
if (textStyle) {
  await textStyle.setAttributes({
    color: "rgba(242, 59, 57, 1)"
  })
}

// Replace breakpoints on a text style.
await textStyle.setAttributes({
  breakpoints: [
    { minWidth: 320, fontSize: "24px" }
  ]
})

// Scale font sizes across all breakpoints without losing them.
await textStyle.setAttributes({
  fontSize: parseInt(textStyle.fontSize) * 0.8 + "px",
  breakpoints: textStyle.breakpoints.map((bp) => ({
    ...bp,
    fontSize: parseInt(bp.fontSize) * 0.8 + "px"
  }))
})

Parameters

Returns

  • Promise<TextStyle | null> – The updated text style, or null if the style was not found.