--- title: Create Explicit Component Variants impact: MEDIUM impactDescription: self-documenting code, no hidden conditionals tags: composition, variants, architecture --- ## Create Explicit Component Variants Instead of one component with many boolean props, create explicit variant components. Each variant composes the pieces it needs. The code documents itself. **Incorrect (one component, many modes):** ```tsx // What does this component actually render? ``` **Correct (explicit variants):** ```tsx // Immediately clear what this renders // Or // Or ``` Each implementation is unique, explicit and self-contained. Yet they can each use shared parts. **Implementation:** ```tsx function ThreadComposer({ channelId }: { channelId: string }) { return ( ) } function EditMessageComposer({ messageId }: { messageId: string }) { return ( ) } function ForwardMessageComposer({ messageId }: { messageId: string }) { return ( ) } ``` Each variant is explicit about: - What provider/state it uses - What UI elements it includes - What actions are available No boolean prop combinations to reason about. No impossible states.