children The children Prop

Last updated: 2026-11-02

children The children Prop

children is a special prop: whatever sits between a component's opening and closing tags automatically becomes props.children. It lets a component wrap arbitrary content, which is the basis of generic containers such as layouts, modals and cards. A container therefore only has to decide how to wrap the content, never what the content should be.

GroupRendering & State
KindPattern
SinceEarliest React versions

ℹ️ Info The editor transpiles JSX to JavaScript and renders the real UI in a sandbox; components mount automatically — no manual render call needed.

📝 Syntax

function Card({ children }) {
  return <div className="card">{children}</div>
}

<Card>Content between the tags is passed to children automatically</Card>

⚙️ Parameters

childrenThe content between the component's tags: strings, JSX, arrays and even functions all end up in this special prop.

Returns:No return value — a coding convention and mental model.

▶ Example

The example runs out of the box: it auto-renders when expanded, and edits take effect instantly.

Output:

Two blue rounded cards: the first wraps a single line of text, the second wraps a bold heading, a paragraph and a button — the same Card container wrapping completely different content.

💡 Key Points

💡 Tip children lets a component care about how to wrap instead of what to wrap, which is the core tool behind composition being better than inheritance.
ℹ️ Info children can be a string, an element, an array, or even a function (the render-props pattern).
⚠️ Warning When several children are passed, children is an array — never assume it is a single element.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q What is props.children?
A It is the content between a component's opening and closing tags. React passes it automatically under the name children, and it is the basis of container components such as layouts, cards and modals.
Q Can I always treat children as an array?
A Not always: with a single child it is that element itself, and only with several children does it become an array. Use the helpers from React.Children when you need a stable shape.
Q When should I use children and when a named prop?
A Nested content fits children naturally (modals, layouts), while configuration data fits named props (title, color); the two are often combined.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏