React › Component Composition & Children Props
What is the children prop in React and how does it work?
IntermediateAnswer
The children prop automatically holds whatever content is placed between the opening and closing tags of a component. It lets a component wrap around any content without needing to know in advance exactly what that content will be.
function Layout({ children }) {
return (
<div className="layout">
<header>My Site</header>
<main>{children}</main>
<footer>Copyright 2026</footer>
</div>
);
}
<Layout>
<h1>Home Page</h1>
</Layout>Real-world example A website reuses the same Layout component on every page, and simply changes what content sits inside the header, main, and footer by passing different children each time.