Development questions
What are slots in LWC and what is the difference between default and named slots?
DevelopmentEasy
Slots let a parent pass markup into a child's template, making components reusable containers.
Child:
html
<template>
<header><slot name="header"></slot></header>
<slot></slot>
</template>
Parent:
html
<c-card>
<span slot="header">Title</span>
<p>Default slot content</p>
</c-card>
- Default (unnamed) slot receives all content without a
slotattribute. - Named slot receives content with a matching
slot="name".
LWC supports slots but not scoped slots.
lwcslotstemplates
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?