composition
Building a component out of smaller components that the consumer assembles, instead of configuring one big component with flags.
In more detail
A composable Card exposes Card, CardTitle and CardBody, and the consumer arranges them. New layouts need no new props, and unused parts are not rendered. Composition hands control of structure back to the consumer.
Related terms
- children prop — The special React prop holding whatever is placed between a component's opening and closing tags.
- slot — A place in a component's layout that the consumer fills with their own content, either through a named prop such as icon or through a Slot component.
- 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.
- boolean prop — A component option that is just true or false, such as isPrimary or hasIcon.
- inheritance — Declaring one class or type as a specialised version of another, so it receives the parent's members and can be used wherever the parent is expected.
- dependency injection — Giving an object the collaborators it needs from outside, usually through its constructor, instead of letting it create or look them up itself.
Taught in
- Design Systems Architecture: Foundations, Layers & Taxonomy — 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
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices
- The Dependency Injection Container: Scopes and Lifetimes — Modern .NET Core, C# & Enterprise Microservices