0Pricing
Sveltejs Academy · Lesson

Checking Slot Content with $$slots

Inspect $$slots to conditionally render wrapper markup only when a slot is used.

Why Check Slots

Sometimes you only want to render wrapper markup (border, header) if the slot has content.

The slots Object

Inside a component, $$slots is an object with a property per filled slot.

All lessons in this course

  1. Default Slots for Content Projection
  2. Named Slots with slot="name"
  3. Slot Fallback Content
  4. Checking Slot Content with $$slots
← Back to Sveltejs Academy