vercel-composition-patterns

Refactor React components by replacing boolean props with explicit variants and compound components.

2.5k|134|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/compozy/compozy --skill vercel-composition-patterns-compozy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/compozy/compozy/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/compozy/compozy --skill vercel-composition-patterns-compozy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React component libraries often suffer from boolean prop proliferation, creating hard-to-maintain conditionals and brittle APIs. This Skill provides structured patterns to replace boolean flags with explicit variants, compound components, and context-enabled providers.

Core Features & Use Cases

  • Explicit variant components (for example ThreadComposer, EditMessageComposer, ForwardMessageComposer) to document and constrain UI variants.
  • Compound components with a shared context and a generic provider interface to decouple state from UI.
  • State-management patterns that lift state into providers, enabling cross-tree sharing and flexible composition in modern React (including React 19).

Quick Start

Create an explicit variant component (e.g., ThreadComposer) that wires a provider, a Frame, an Input, and a Submit button to demonstrate the pattern.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I eliminate boolean prop proliferation when refactoring React components?

Eliminate boolean prop proliferation by replacing conditional flags with explicit variant components, compound components, and context-enabled providers. This approach documents UI variants structurally, reducing brittle APIs and hard-to-maintain conditionals in large component libraries.

What is the compound component pattern in React and how does it help scale UI libraries?

The compound component pattern decouples state from UI by sharing context across sub-components. It enables flexible composition and cross-tree state sharing, allowing large React component libraries to scale without prop drilling or rigid parent-child dependencies.

How do I lift state into a provider for cross-tree sharing in modern React?

Lift state into a provider interface to enable cross-tree sharing and flexible composition. This pattern uses generic context interfaces to decouple state management from UI rendering, supporting modern React 19 API usage and scalable component architectures.

Does this React composition pattern work with React 19 APIs?

Yes, these composition patterns satisfy modern React 19 API usage. They apply provider-based state lifting, generic context interfaces, and compound component designs that leverage current React features for building reusable and flexible UIs.

What's the best way to structure explicit variant components instead of using boolean flags?

Structure explicit variant components as separate, dedicated components such as ThreadComposer, EditMessageComposer, or ForwardMessageComposer. Each variant wires its own provider, Frame, Input, and Submit button, documenting and constraining UI variants without boolean conditionals.

When should I avoid boolean props in React component APIs?

Avoid boolean props when components accumulate multiple flags creating hard-to-maintain conditionals and brittle APIs. Replace them with explicit variants and context-enabled providers when refactoring large component libraries or building reusable, flexible UIs requiring scalable composition.