Passing JSX as Regular Props
You'll learn how to pass JSX elements as named props just like strings or numbers, giving you explicit control over where content appears without relying on the children prop.
The Core Idea
You already know JSX elements are just objects. That means you can pass them as any prop, not just children. Instead of wrapping content between component tags, you pass JSX through explicitly named props like header={<h1>Title</h1>} or footer={<button>Close</button>}.
This is the slot pattern in action: you're filling named placeholders with specific content.
Why This Matters
Sometimes children isn't enough. A card component might need a header, body, and footer—three separate content areas. Passing JSX as regular props makes this explicit:
<Card
header={<h2>Product Title</h2>}
body={<p>Description here</p>}
footer={<button>Buy Now</button>}
/>
Inside Card, you render each prop wherever it belongs:
function Card({ header, body, footer }) {
return (
<div className="card">
<div className="card-header">{header}</div>
<div className="card-body">{body}</div>
<div className="card-footer">{footer}</div>
</div>
);
}
No wrapper components, no compound pattern—just straightforward prop passing.
Think of It Like This
It's like ordering a custom sandwich: instead of handing the chef ingredients in one bag (children), you tell them exactly what goes where—"lettuce on bottom tier, tomato on middle, cheese on top." Each prop is a labeled slot.
Key Takeaway: Passing JSX as regular props lets you explicitly control multiple content areas without relying on children, making your component's API clear and predictable.