React Composition PatternsVercel / information

Flexible component APIs

Make the
parts fit.

Turn a component full of mode flags into explicit pieces you can read, share and compose.

8 GUIDELINESORIGINAL SOURCEMIT
Thread
Edit
Forward

EXPLICIT PARTS / SHARED CONTRACT

Different interfaces.
One shared state contract.

3 variantsThread, edit and forward in the worked fixture
12 checksReal local browser behavior checks passed
14 filesOriginal upstream files preserved byte-for-byte

What changes

An interface built from choices you can see.

Compose the structure

Replace overlapping boolean modes with named variants and compound components. Use children to show exactly what each interface contains.

Share the contract

Separate state management from the UI. A provider exposes state, actions and metadata so the same pieces can work with different implementations.

Bring

Your component source

React version, existing code, required variants, state ownership, keyboard behavior and a list of behavior that must stay the same.

Receive

A clearer component API

Source changes, explicit variants, shared pieces and a reasoned provider boundary. A capable coding assistant applies the guidance; this package is not an automatic refactoring executable.

For code that is outgrowing its switches.

A good fit

  • Component library maintainers.
  • React teams adding variants to an existing feature.
  • Reviews of render props, state boundaries or reusable APIs.

A different job

  • Choosing a visual brand or redesigning a website.
  • Scanning every deprecated API before a React upgrade.
  • Measuring bundle size, rendering speed or business impact.

Evidence in context

Behavior survived the local refactor.

Actual local React browser run showing before-and-after components and twelve passing behavior checks
ACTUAL RUN SCREENSHOT
Saved from the locally running React fixture after browser interaction checks. Codex authored the fixture from the original guide; it is test material, not an upstream app or a recorded customer project.
Twelve checks passed on a single synthetic React 19.3.1 fixture, covering state sharing, submission payloads, cancellation, keyboard input and ref focus. This is a bounded worked example, not a performance benchmark or proof for every application.

Use it with your coding assistant.

Read SKILL.md, then the relevant rules or the full compiled AGENTS.md. The package contains instructions and examples, with no required package install or vendor API key of its own. A compatible assistant, source access and model access are still required; model usage may have separate costs.

Version matters. React 19 examples use context via use() and ref as a prop. Skip those examples for older React. useContext() remains a supported React API. Examples contain app-specific components and hooks that you must supply.

Source: vercel-labs/agent-skills · composition-patterns
Commit: 1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62. The upstream Skill and repository README declare MIT. All original attribution is retained; the pinned upstream does not contain a standalone LICENSE file.