compound component
A set of components designed to be used together, such as Tabs, Tabs.Trigger and Tabs.Panel, that share state behind the scenes.
In more detail
The root holds the state and provides it through React Context; each part reads what it needs. Consumers arrange the parts freely without wiring state themselves. Parts should throw a clear error if used outside their root, and the root should generate unique IDs so several instances on one page do not collide.
Related terms
- React Context — A React feature that lets a parent component make a value available to every component below it without passing it as props.
- useId — The React hook that generates a unique ID string that is stable across renders and matches between server and browser.
- composition — Building a component out of smaller components that the consumer assembles, instead of configuring one big component with flags.
- prop getter — A function returned by a headless hook, such as getTriggerProps(), that gives back the attributes and event handlers an element needs.
- inversion of control — A design in which a piece of code gives up control of some decisions, such as how its dependencies are created or what it renders, to the code around it.
- custom hook — Your own function whose name starts with use and that calls other hooks, packaging stateful logic so several components can reuse it.
- static property — A property attached to a function or class itself rather than to its instances, such as Tabs.Item.
Taught in
- Design Systems Architecture: Foundations, Layers & Taxonomy — Design Systems & Component Engineering
- Headless Architecture: State vs Presentation Separation — Design Systems & Component Engineering
- Component API Ergonomics: Composition vs Boolean Config Props — Design Systems & Component Engineering
- Compound Component Patterns: Context Sharing & Internal State — Design Systems & Component Engineering
- useContext in Depth: Scoping, Consumer Subscription Costs — React 19 & Modern Component Architecture
- Compound Components: Inversion of Control with Context — React 19 & Modern Component Architecture