Composition vs configuration: should design system components take lots of props or use slots?
Every mature component library eventually hits this tension. A card, dialog or list item starts simple, then requests pile up: an icon here, a badge there, an optional footer, a second button. There are two broad ways to respond.
Configuration adds props: title, subtitle, icon, badge, footerAction, variant. Consumers fill in the blanks and the component decides the layout.
- Pros: very consistent output, easy to document, hard to misuse.
- Cons: the prop list grows endlessly, and every new need requires a system change.
Composition exposes smaller parts that consumers assemble: Card, Card.Header, Card.Media, Card.Body, Card.Footer. The component provides structure and styling; teams decide what goes inside.
- Pros: flexible, fewer requests to the system team, closer to how HTML itself works.
- Cons: more ways to build inconsistent layouts, and docs must show good recipes.
A practical rule of thumb
- Use configuration for small, high-consistency components: buttons, badges, inputs, toggles.
- Use composition for containers and layouts: cards, dialogs, tables, page headers.
- Offer pre-built "recipes" of composed components for the most common cases, so teams get speed without losing flexibility.
Design tools mirror this choice too. Figma components with many boolean properties are the configuration approach; slot-like instance swaps lean toward composition.
Where does your library sit on this spectrum? Have you ever had to split a "god component" with dozens of props into composable parts?
Comments · 2
Slots keep things flexible, while props keep usage predictable. A mixed approach like a few props for common cases plus slots for the rest worked for us.
If a component has more than about eight props, it's probably doing too much. Composition scales better in code review too.