Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Routing and Application Architecture
Stage 5: Specialization (pick ONE)

Part 02 / Topic 4 of 7

Slots: passing JSX through props that are not children

PageSection above takes this one step further than WalletSummary's Panel: header and footer are also JSX, but they arrive as named props, not as children. A component can expose as many of these "slots" as it needs - children is really just the one slot JSX gives special tag-body syntax for; everything else is a prop like any other.

// examples/02_children_and_slots.jsx
export function ProductDetailPage({ name, description, price }) {
  return (
    <PageSection
      header={<h2>{name}</h2>}
      footer={<button>{`Buy for ₹${price.toLocaleString("en-IN")}`}</button>}
    >
      <p>{description}</p>
    </PageSection>
  );
}

ProductDetailPage never mentions "slot" anywhere in its own code - it just hands three pieces of JSX to three different props (one of them via the children tag-body shorthand, two of them by name). PageSection does not know, or need to know, that it is being used for a product page. Rendering <ProductDetailPage name="Pressure Cooker 5L" description="Stainless steel, induction compatible." price={1899} /> really shows (React 19.3.1, examples/02_children_and_slots.test.jsx):

Pressure Cooker 5L
Stainless steel, induction compatible.
Buy for ₹1,899

This is the same composition idea as section 3, just with more than one fillable region. Stage 2's Expense Tracker UI project and Stage 4's capstone both lean on exactly this pattern for layout components (a page shell with a header slot, a body via children, and an optional footer/actions slot).

Done here? The practice set for Part 2 — including the solutions — is on the part page.

Search the guide