Skip to content

Bindings, Actions & Transitions

Connecting components to the DOM and to motion

Section titled “Connecting components to the DOM and to motion”

Runes give you reactive state; this module covers the directives that connect that state to real DOM elements and to visual motion:

  • Bindings (bind:) create a two-way link between state and a DOM property — the input updates the state, and the state updates the input.
  • Attachments and actions — {@attach} (Svelte 5.29+) runs imperative setup on an element or component and re-runs when its inputs change; use: actions are the legacy form for libraries that still ship them. The escape hatch for third-party libraries, focus, tooltips, and click-outside.
  • Transitions & animations (transition:, animate:) declaratively animate elements as they enter, leave, and reorder.
LessonWhat you’ll learn
Bindingsbind:value, bind:this, bind:group, and component bindings
ActionsAttachments ({@attach}) first, then the legacy use: directive and fromAction
Transitions & animationstransition:/in:/out: and animate:flip
Forms & inputsControlled inputs, validation, and submit handling
flowchart TB
  state["reactive state (runes)"] --> bind["bind: two-way link to DOM props"]
  state --> action["use: imperative setup on an element"]
  state --> trans["transition: / animate: declarative motion"]
  bind --> dom["the DOM"]
  action --> dom
  trans --> dom
Three ways Svelte reaches the DOM
What does a bind: directive create?
What is a use: action for?
What do transition: and animate: directives do?