building-compound-components

Build unstyled composable React components with context-based state sharing.

11.2k|562|Updated Jun 15, 2024
One-click install
npx skills add https://github.com/tambo-ai/tambo --skill building-compound-components
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: building-compound-components
Source: https://github.com/tambo-ai/tambo/tree/main/.claude/skills/compound-components
Command: npx skills add https://github.com/tambo-ai/tambo --skill building-compound-components

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams create unstyled, composable React components that separate business logic from presentation.

Core Features & Use Cases

  • Unstyled, composable, context-driven components following Radix/UI patterns.
  • Supports multiple usage patterns: Direct children, Render props, Sub-contexts, and asChild polymorphism for flexible rendering.
  • Ideal for building component libraries, headless UI primitives, and design system foundations.

Quick Start

Create a new compound component by defining Root, Content, and Trigger components, wire them with context, and render your app with styled wrappers or CSS variables.

Frequently Asked Questions about building-compound-components

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

FAQPage Schema
How do I build headless UI primitives in React?

You build headless UI primitives by creating unstyled, composable React components that separate business logic from presentation. This involves using context to share state across components while leaving all visual styling to the consumer.

What is the compound components pattern in React?

The compound components pattern in React is a design architecture where multiple components share state through context to form a unified UI element. It enables flexible rendering through direct children, render props, and sub-contexts.

How do I use render props and asChild polymorphism in React components?

You implement render props and asChild polymorphism to enable flexible rendering in React components. These composition patterns allow components to share context-driven state while giving consumers control over the rendered DOM structure.

Can I separate business logic from presentation in a React component library?

Yes, you can separate business logic from presentation in a React component library by building unstyled, composable primitives. This architecture uses context, forwardRef, and safe TypeScript typings to maintain clean namespace exports.

Does this approach work for creating Radix-style design system foundations?

Yes, creating Radix-style design system foundations is directly supported by building unstyled, context-driven components. This method provides the necessary composition patterns and safe TypeScript typings for robust UI primitives.

What are the limitations of building unstyled React components?

A limitation of building unstyled React components is that they provide no default presentation layer, requiring consumers to implement all visual styling. The core logic handles only state management and context sharing.