Back to results for “Components & JSX”
React › Component Composition & Children Props

What is the difference between passing a component as a prop and nesting it as children?

Beginner

Answer

Nesting as children is the natural way of writing JSX where content sits between opening and closing tags, and it reads like regular HTML. Passing a component as a named prop is useful when a component needs more than one separate piece of content in different places, since children alone only gives you a single slot.
// Nested as children, one slot
<Card>
  <p>Main content</p>
</Card>

// Passed as a named prop, extra slot
<Card footer={<Button>Save</Button>}>
  <p>Main content</p>
</Card>
Real-world example A settings page component nests its main form fields as children, but passes its save button separately as a footer prop, giving the parent control over exactly where the button appears.

Common follow-ups: Can you mix children and named component props in the same component?;Which approach is easier for a new developer joining the team to understand?