0Pricing
Sveltejs Academy · Lesson

Default Prop Values

Assign fallback values to props when the parent does not supply them.

Why Defaults

Defaults make a component usable without every consumer passing every prop. They define the fallback behavior.

Inline Default

Assign a value when declaring the prop.

export let label = "Click me";

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