0Pricing
Sveltejs Academy · Lesson

Action Parameters and Updates

Pass parameters to actions and react to parameter changes with the update method.

Parameterized Actions

Actions can accept a second argument: parameters from the consumer.

function tooltip(node, text) {
  // ...
}

Apply with Parameters

Pass the value with curly braces after the colon.

<button use:tooltip={"Save document"}>Save</button>

All lessons in this course

  1. use: Directive Syntax
  2. Action Parameters and Updates
  3. The destroy() Cleanup Function
  4. Practical Actions: clickOutside tooltip autofocus
← Back to Sveltejs Academy