0Pricing
Sveltejs Academy · Lesson

Forwarding Props with $$props and $$restProps

Pass all or remaining props through to an inner element or component.

Why Forward Props

Wrapper components often need to pass all received props to an inner element. Forwarding avoids listing every attribute.

The $$props Object

Inside a component, $$props is an object containing every prop passed to the component.

<script>
  // $$props is auto-injected
</script>

<input {...$$props} />

All lessons in this course

  1. Declaring Props with export let
  2. Passing Props from Parent
  3. Default Prop Values
  4. Forwarding Props with $$props and $$restProps
← Back to Sveltejs Academy