Create interaction
webflow.interactions.create(params)
Create a new interaction. If the Interactions panel is set to Interactions with GSAP and the interaction is visible on the current page, the Designer selects it. Selecting it opens the timeline bar on the canvas. Component-scoped interactions and pages scopes that omit the current page are not selected.
Syntax
Parameters
- params.pageId : string - The page the interaction is authored on.
- params.name : string - Display name of the interaction.
- params.triggers : InteractionTrigger[] - Triggers for the interaction.
- params.timelines : InteractionTimelineInput[] - Timelines with actions resolved inline.
- params.scope : InteractionScopeInput - Where the interaction applies. When omitted it is site-wide (fires on every page), not scoped to
pageId. Pass{type: 'pages', value: [pageId]}to limit it to this page. Default:{type: 'site'}. - params.conditionalPlayback : InteractionConditionalPlaybackItem[] - Reduced-motion or breakpoint playback rows.
Omit timelineDefaults. create rejects any value.
For every field and value these parameters accept, see Interaction schema.
Returns
Promise<Interaction>
A Promise that resolves to the created interaction, with generated ids and resolved timelines.
Example
The wf:class target below assumes a hero-btn class already exists on the site. The Designer resolves the class slug to a style block id when it saves. It rejects a slug that matches no class, or more than one.
For click, hover, scroll, mouse move, and custom event examples, see Interaction examples.