vercel-composition-patterns

Apply React composition patterns to replace boolean props with compound components.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Lschulzes/meal-planning --skill vercel-composition-patterns-lschulzes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/Lschulzes/meal-planning/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/Lschulzes/meal-planning --skill vercel-composition-patterns-lschulzes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Codebases often accumulate boolean props that explode combinations and complicate reuse. This guide presents patterns to replace booleans with compound components, shared context, and explicit variants to improve maintainability and scalability.

Core Features & Use Cases

  • Explicit variants: ThreadComposer, EditMessageComposer, ForwardMessageComposer, and other explicit variants to keep architecture self-documenting.
  • Compound components & context: Build complex UIs by composing small parts that read from a shared provider, reducing prop drilling.
  • State lifting & dependency injection: Move state into providers so UI remains UI-only and swapping implementations is straightforward.
  • Use cases include refactoring large component libraries, designing reusable component APIs, and building scalable UI systems.

Quick Start

Install a React project configured with these patterns and begin by inspecting the explicit variant components like ThreadComposer and EditMessageComposer to see composition in action.

Frequently Asked Questions about vercel-composition-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce boolean prop explosion in React components?

To reduce boolean prop explosion in React components, replace booleans with explicit variants, compound components, and shared context. This approach prevents the combinatorial complexity that complicates reuse and keeps architecture self-documenting.

What is the best way to build compound components with shared state in React?

Building compound components with shared state in React is best achieved by composing small UI parts that read from a shared provider. This state lifting and dependency injection technique moves state into providers, reducing prop drilling and keeping UI components implementation-agnostic.

How do I refactor a large React component tree to use explicit variants?

Refactoring a large React component tree to use explicit variants involves creating distinct components like ThreadComposer and EditMessageComposer instead of overloading a single component with booleans. This separates concerns and improves API flexibility across large user interfaces.

Does React composition patterns usage require forwardRef?

React composition patterns usage in this context avoids forwardRef entirely. It enforces React 19 API conventions, specifically utilizing the use() hook instead of useContext for shared state, to simplify component APIs and modernize state management.

When should I use explicit variants over boolean props in React?

You should use explicit variants over boolean props in React when designing reusable component APIs or scaling UI systems. Explicit variants prevent invalid component states and make the architecture self-documenting, whereas boolean props create complex, hard-to-maintain combinations.