building-components

Guide developers to build accessible UI components using Root/Item/Trigger/Content patterns.

6|Updated Mar 24, 2019
One-click install
npx skills add https://github.com/rafifos/dotfiles --skill building-components-rafifos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: building-components
Source: https://github.com/rafifos/dotfiles/tree/main/dot_agents/skills/building-components
Command: npx skills add https://github.com/rafifos/dotfiles --skill building-components-rafifos

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This guide helps teams build modern, accessible, and composable UI components by outlining patterns for structure, accessibility, design token theming, and integration with distribution ecosystems like npm or registries.

Core Features & Use Cases

  • Establishes a clear Root/Item/Trigger/Content component pattern to enable composability and predictable API evolution.
  • Covers accessibility best practices (ARIA roles, keyboard navigation, focus management) and design-token driven theming.
  • Demonstrates polymorphism patterns (asChild, as) and data-slot/data-state strategies to enable flexible composition with existing components.
  • Provides guidance for publishing, documentation, and design system integration to accelerate reuse across apps.

Quick Start

Create a small accordion example using Root, Item, Trigger, and Content components to validate the pattern.

Frequently Asked Questions about building-components

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

FAQPage Schema
How do I build accessible UI components that are easy to compose?

To build accessible UI components that are composable, use a structured Root/Item/Trigger/Content pattern combined with design tokens. This approach enforces predictable API evolution and incorporates ARIA roles, keyboard navigation, and focus management best practices directly into the component architecture.

What is the Root/Item/Trigger/Content pattern for component composition?

The Root/Item/Trigger/Content pattern is a structural design for component composition that separates container elements from interactive elements. It establishes predictable APIs by dividing responsibilities, allowing developers to build flexible primitives using polymorphism strategies like asChild or as and data-slot attributes.

How do I apply design tokens for theming across UI components?

Design tokens are applied for theming by integrating them into the component architecture as style variables. This token-driven approach decouples visual properties from component logic, enabling consistent theming across applications and simplifying integration into larger design systems.

Does this component pattern support polymorphism with existing components?

Yes, the component pattern supports polymorphism with existing components through asChild and as strategies. These patterns enable flexible composition by allowing components to inherit the behavior of the pattern while rendering as different underlying elements or integrating with existing UI libraries.

How do I publish UI components to a design system or registry?

To publish UI components to a design system or registry, organize the project with optional scripts, references, and assets directories for on-demand usage. Include frontmatter with name and description, ensure registry-compatible organization, and document components to accelerate reuse across apps.

What accessibility features should I include when building modern UI components?

Accessibility features for modern UI components must include ARIA roles, keyboard navigation, and focus management. Structuring components with the Root/Item/Trigger/Content pattern ensures these accessibility best practices are consistently applied across all interactive primitives.