Skip to main content

applyAnimationStyle

Applies a Motion animation style to this node and returns the applied animation style instance id.

Signature​

applyAnimationStyle(styleId: string, animationStyleData?: AnimationStyleConfiguration): string

Parameters​

styleId​

The animation style to apply. For a Figma animation style, the styleId from figmaAnimationStyles. For a custom animation style, the id of a CustomAnimationStyle.

animationStyleData​

Optional values used to configure the applied animation style. Omit type, or set it to "FIGMA", for a Figma animation style; set it to "CUSTOM" to apply a custom animation style.

Remarks​

const node = figma.currentPage.selection[0]
const [style] = figma.motion.figmaAnimationStyles()
if (node && style) {
const appliedStyleId = node.applyAnimationStyle(style.styleId, {
duration: 0.4,
timelineOffset: 0,
props: {
direction: 'right',
distance: 120,
},
})
console.log(appliedStyleId)
}