vercel-composition-patterns

Replace boolean prop toggles with compound components and shared context in React.

1|Updated Apr 13, 2015
One-click install
npx skills add https://github.com/tyler-dot-earth/.dotfiles --skill vercel-composition-patterns-tyler-dot-earth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/tyler-dot-earth/.dotfiles/tree/main/agents/skills/composition-patterns
Command: npx skills add https://github.com/tyler-dot-earth/.dotfiles --skill vercel-composition-patterns-tyler-dot-earth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Addresses the challenge of boolean prop proliferation by guiding refactors toward explicit composition using compound components, context providers, and scalable APIs.

Core Features & Use Cases

  • Explicit variants: Provide dedicated components like ThreadComposer, EditMessageComposer, and ForwardMessageComposer to replace boolean prop combos.
  • Compound components with shared context: Structure UI as a set of interdependent parts that read from a shared context rather than through props.
  • Provider-based state lifting: Move state management into providers so UI components can be reused with different state implementations.
  • React 19 API guidance: Illustrates use() over useContext and avoids unnecessary forwardRef usage.

Quick Start

Create a minimal React example showing a ThreadComposer variant using a provider and a Frame with header, input, and submit.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I fix boolean prop proliferation in React components?

Compound components in React work by structuring interdependent UI parts that read from a shared context provider rather than receiving data through props. This pattern enables flexible component composition while keeping state management centralized.

How do I lift state into providers for React component libraries?

Lifting state into providers for React component libraries involves moving state management into context providers so UI components remain decoupled. This allows components to be reused with different state implementations without modifying their internal logic.

When should I use explicit variants instead of boolean props in React?

Explicit variants should be used instead of boolean props in React when building scalable component libraries. Dedicated components like EditMessageComposer and ForwardMessageComposer provide clearer APIs than boolean combinations, improving maintainability and developer experience.

Does this React composition pattern work with React 19 APIs?

A limitation of provider-based state lifting is that it requires a basic React setup with components, a provider, and a state management approach. You should not use this pattern if your application is too simple to benefit from decoupled UI and state architecture.