Vercel composition patterns

From ariadoss/superskills · View interactive version

Vercel composition patterns is an AI agent skill from the GitHub repository ariadoss/superskills. React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 AP

How to use this skill

Skill file

React Composition Patterns

Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.

When to Apply

Reference these guidelines when:

Rule Categories by Priority

| Priority | Category | Impact | Prefix |

| -------- | ----------------------- | ------ | --------------- |

| 1 | Component Architecture | HIGH | architecture- |

| 2 | State Management | MEDIUM | state- |

| 3 | Implementation Patterns | MEDIUM | patterns- |

| 4 | React 19 APIs | MEDIUM | react19- |

Quick Reference

1. Component Architecture (HIGH)

2. State Management (MEDIUM)

3. Implementation Patterns (MEDIUM)

4. React 19 APIs (MEDIUM)

⚠️ React 19+ only. Skip this section if using React 18 or earlier.

Core Principle

Avoid boolean prop proliferation. When a component accumulates boolean props like isLarge, isLoading, hasIcon, showFooter, it becomes a configuration panel instead of a component. This pattern:

Instead, compose. Create explicit variant components, lift state into providers, and use children for flexible content injection.

Example: Boolean Props → Composition

// ❌ Boolean prop proliferation
<Button isLarge isLoading hasLeftIcon={<IconSpinner />} disabled={isLoading}>
  Submit
</Button>

// ✅ Explicit variants + composition
<Button.Large disabled={isLoading}>
  {isLoading ? <Spinner /> : null}
  Submit
</Button.Large>

Compound Component Pattern

// Provider holds shared state
function Tabs({ children, defaultTab }) {
  const [active, setActive] = useState(defaultTab);
  return (
    <TabsContext.Provider value={{ active, setActive }}>
      {children}
    </TabsContext.Provider>
  );
}

// Children consume via context
Tabs.Tab = function Tab({ id, children }) {
  const { active, setActive } = useContext(TabsContext);
  return (
    <button
      onClick={() => setActive(id)}
      aria-selected={active === id}
    >
      {children}
    </button>
  );
};

// Usage is readable and composable
<Tabs defaultTab="overview">
  <Tabs.Tab id="overview">Overview</Tabs.Tab>
  <Tabs.Tab id="details">Details</Tabs.Tab>
</Tabs>
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.