When learning React, you’ll quickly come across a special prop called children. It may look like an ordinary prop, but it works very differently and is one of the most powerful features in React.
This post explains what children is, why it exists, and how to use it with simple, clear examples.
⭐ What Is the children Prop?
In React, children is a built-in prop automatically provided by React. It represents everything placed between a component’s opening and closing tags.
Example:
<Card>
<p>Hello!</p>
</Card>
Here, React automatically passes this:
<p>Hello!</p>
as a prop named children to the Card component.
You do not have to create or pass children manually — React does it for you.
⭐ How React Sends children to Our Component
Inside the component, we can receive it like any other prop:
Option 1: Using props.children
function Card(props) {
return <div>{props.children}</div>;
}
Option 2: Using object destructuring (more common)
function Card({ children }) {
return <div>{children}</div>;
}
Both are correct.
Destructuring simply makes the code cleaner.
⭐ What Can children Contain?
One of the best things about React is that children can be almost anything:
✔ A string
<Card>Hello World</Card>
✔ A JSX element
<Card><p>Hello World</p></Card>
✔ Multiple elements
<Card>
<h1>Title</h1>
<p>Subtitle</p>
</Card>
✔ An array of elements
<Card>{[<li>One</li>, <li>Two</li>]}</Card>
✔ Another component
<Card><Profile /></Card>
✔ A function (advanced pattern)
<Card>{() => <p>Hello!</p>}</Card>
React handles all of these gracefully.
⭐ Why Is children Useful?
The children prop allows us to create reusable and flexible components.
For example, a Card component can be used like this:
<Card>
<h2>Welcome</h2>
<p>This is a simple card.</p>
</Card>
Or like this:
<Card>
<img src="photo.jpg" />
</Card>
Or even like this:
<Card>
<button>Click Me</button>
</Card>
The same component works for different layouts, text, and elements — because children handles whatever we put inside.
⭐ Example: A Simple Reusable Card Component
function Card({ title, children }) {
return (
<div className="card">
<h3>{title}</h3>
{children}
</div>
);
}
Usage:
<Card title="Profile">
<p>Name: Heartin</p>
<p>Age: 16</p>
</Card>
Here, everything inside <Card>...</Card> becomes the children prop.
⭐ children vs Other Props
A normal prop:
<Card title="Welcome" />
is passed manually by us.
But:
<Card>Some content</Card>
is passed automatically by React as children.
So:
| Prop Type | Provided By | Example |
|---|---|---|
| Custom prop | Us | title="Hello" |
children | React | <Card>Hello</Card> |
⭐ Can We Combine children With Other Props?
Absolutely!
function Card({ title, children }) {
return (
<div className="card">
<h2>{title}</h2>
<div>{children}</div>
</div>
);
}
Usage:
<Card title="My Card">
<p>This is inside the card.</p>
</Card>
⭐ Summary
Here’s what beginners should remember:
childrenis a special built-in prop in React.- It contains whatever you place between a component’s tags.
- You don’t manually create or pass it — React does that.
- It can be text, elements, components, arrays, or even functions.
- It makes your components reusable, flexible, and powerful.
- Many UI components (Card, Modal, Layout, Wrapper, Container) rely heavily on
children.
Once you understand how children works, you’ll write cleaner and more reusable React components.