0Pricing
Sveltejs Academy · Lesson

Forwarding Events with on:click

Re-emit component events to the parent using the bare on: directive.

Event Forwarding

To re-emit a child element's event up through your component, write on:event with no handler.

Basic Forwarding

This forwards the inner button's click to the consumer of MyButton.

<button on:click>Click</button>

All lessons in this course

  1. on:click on:input on:submit
  2. Event Modifiers: preventDefault stopPropagation once
  3. Custom Events with createEventDispatcher
  4. Forwarding Events with on:click
← Back to Sveltejs Academy