Composition with children in React
From the React Components & JSX cheat sheet Ā· Component Patterns & Types Ā· verified Jul 2026
Composition with children
Use the children prop to build flexible, composable layout components
jsx
function Card({ children }) {
return <div className="card">{children}</div>;
}
function App() {
return (
<Card>
<h2>Title</h2>
<p>Content</p>
</Card>
);
}š” Composition is React favorite pattern ā solves most "inheritance" needs cleanly
ā” Use named slot props (header, sidebar) when you need multiple "children" areas
š Composition avoids prop drilling without needing Context for layout components
š¢ Function-as-children gives the parent control while letting children access internal data
compositionchildrenslots