About compound-ui
compound-ui is a skill for building source-owned React components with composable parts and accessible primitives. It guides developers through inspecting a project, defining component APIs, implementing components, and reviewing behavior.
Key features
- 01Inspect existing UI stack and conventions
- 02Define component contracts before coding
- 03Compose named parts with children
- 04Use accessible primitives and styling hooks
- 05Review types, keyboard behavior, and responsiveness
Use cases
- 01Adding a compound React component to an existing project
- 02Matching component composition to the project's primitive library
- 03Checking accessibility and behavior before finishing UI work
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill compound-uiAfter installing, type/compound-uiin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/authoring-patterns.mdcomponent-contract.mdreview-checklist.mdsource-map.mdDetails
From the project READMECompound UI
Use this skill to create source-owned React components that compose like shadcn/ui: small named parts, explicit children, accessible primitives, class merging, and stable styling hooks.
Workflow
- Inspect the local UI stack before writing code:
- Read nearby project guidance, existing component files, package versions, styling utilities, primitive libraries, and test/story conventions.
- Prefer the project's existing export, file, styling, icon, and accessibility patterns.
- Refresh docs when exact APIs matter:
- Use references/source-map.md for current source links and captured guidance.
- Prefer current React, shadcn/ui, and local primitive docs (Radix UI, Base UI, or React Aria) before changing framework-sensitive code.
- Detect the project's primitive base first:
components.jsonstyle/ imports ofradix-ui,@base-ui/react, orreact-aria-components. Match its composition API instead of mixing bases.
- Design the public API before implementation:
- Read references/component-contract.md.
- Define the root component, named subcomponents, legal nesting, controlled/uncontrolled state, and required accessibility parts.
- Implement in the shadcn style:
- Read references/authoring-patterns.md.
- Export source-owned named parts with
data-slot,classNamemerging, prop/ref pass-through, and minimal behavior props.
- Review before finishing:
- Use references/review-checklist.md.
- Verify typecheck, lint, story/browser behavior, keyboard support, focus, accessible names, and responsive states when relevant.
Enforcement Rules
- Prefer compound parts and
childrenover prop-heavy wrapper APIs. Do not createtitle,description,actions,icon,isLoading, or layout props when named subcomponents express the same structure better. - Keep acceptable props narrow: DOM props,
className,children, the element-swap prop of the project's primitive base (asChildfor Radix,renderfor Base UI), controlled state, event handlers, accessibility props, and intentional variants such asvariantorsize. - Use existing accessible primitives for complex behavior such as dialogs, menus, popovers, tabs, selects, tooltips, comboboxes, accordions, and roving focus.
- Preserve primitive contracts. Custom slotted children must spread incoming props and support refs according to the project's React version.
- Add
data-slotto every exported part, plus state/variant data attributes when useful for styling and tests. - Keep state local unless parts must coordinate. Use scoped context only for compound coordination and fail loudly when a required part is used outside its root.
- Add
"use client"only when the component uses hooks, events, browser APIs, or client-only primitives. - Do not hide required accessibility behind convenience defaults that callers cannot inspect or override.
Comments
Markdown supported