react-component-patterns

Implement reusable React component patterns with Compound Components, Render Props, and Polymorphic Components.

Updated Apr 20, 2026
One-click install
npx skills add https://github.com/vincent119/ai-rules-kit --skill react-component-patterns-vincent119
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-component-patterns
Source: https://github.com/vincent119/ai-rules-kit/tree/main/skills/react-component-patterns
Command: npx skills add https://github.com/vincent119/ai-rules-kit --skill react-component-patterns-vincent119

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing scalable, reusable React user interfaces often requires composing small components into richer, interactive elements while maintaining clean, shared state across nested parts of the UI.

Core Features & Use Cases

  • Compound Components: share state via Context and compose child components.
  • Polymorphic Components (as prop): render different HTML elements or components without duplicating logic.
  • Render Props: delegate rendering decisions to consumers for flexible data flow.
  • Slot Pattern: expose named slots to customize layout while keeping internal logic encapsulated.
  • Controlled & Uncontrolled Patterns: support both external state control and internal state management.

Quick Start

Start by implementing a Compound Components pattern to share state via context and progressively compose child components.

Frequently Asked Questions about react-component-patterns

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

FAQPage Schema
How do I share state across nested React components without excessive prop drilling?

You can share state across nested React components by implementing the Compound Components pattern, which leverages React Context to implicitly pass shared state to child components, resulting in cleaner and more composable UI structures.

What is the best way to build a React component that renders different HTML elements without duplicating logic?

The best way to render different HTML elements without duplicating logic is using Polymorphic Components with the `as` prop pattern, enabling a single component to dynamically render varying tags while maintaining internal structural consistency.

How do I use render props in React to customize component rendering logic?

You use render props in React by passing a function as a prop, delegating rendering decisions to the consumer component for flexible data flow and dynamic UI customization without complex internal state management.

Can I support both controlled and uncontrolled state management in a single reusable React component?

Yes, you can support both controlled and uncontrolled state management within a single reusable React component by implementing both patterns concurrently, allowing consumers to either manage state externally or rely on internal component state.

When should I use the slot pattern for React component layout customization?

You should use the slot pattern for React component layout when you need to expose named slots for custom arrangement, allowing consumers to inject specific UI elements while keeping internal logic fully encapsulated.

Does this React component patterns approach work for building scalable UI libraries?

Yes, these React component patterns are explicitly designed for building scalable UI libraries, providing modular composition via Compound Components, Polymorphic props, and Render Props to improve UI composability across diverse applications.