component-api
Skill1 starsChanged 3 months agoMITView on GitHub
The cross-cutting prop contract every component skill speaks — one shared dialect so ten independently-built components read as authored, not assembled. Fixes the canonical prop vocabulary (variant/size/tone), cva()-based variants that resolve to tokens never literals, asChild polymorphism via Radix Slot (never a custom `as` prop), the cn()/tailwind-merge order that lets a caller's className win, data-slot part targeting and ref-as-prop forwarding for React 19, controlled/uncontrolled parity, and native-attribute + a11y pass-through. Invoke in the Foundation phase after tokens and before the component tier, whenever building or restyling any component (buttons, cards, forms, pricing, data-display, hero…), deciding a prop name, adding a variant, or when the user says "the props are inconsistent", "name this prop", "should this be asChild", "why do the components feel assembled", or a component invents its own variant vocabulary.
In this repository79 other files it gives its agents.
- ultrawebSkill
- analyticsSkill
- animejsSkill
- api-designSkill
- app-structureSkill
- assetsSkill
- authSkill
- award-canonSkill
- briefSkill
- buttonsSkill
- cardsSkill
- cartSkill
- checkpointSkill
- colorSkill
- command-paletteSkill
- consentSkill
- content-cmsSkill
- copywritingSkill
- databaseSkill
- data-displaySkill
- data-fetchingSkill
- depthSkill
- directionSkill
- emailSkill
- faqSkill
- feature-sectionsSkill
- footerSkill
- formsSkill
- gate-accessibilitySkill
- gate-antislopSkill
- gate-codeSkill
- gate-contentSkill
- gate-performanceSkill
- gate-responsiveSkill
- gate-visualSkill
- handoffSkill
- heroSkill
- hidden-craftSkill
- i18nSkill
- iconsSkill
- identitySkill
- imagerySkill
- iterateSkill
- layout-gridSkill
- marginaliaSkill
- media-optimizationSkill
- micro-interactionsSkill
- mockupSkill
- motion-languageSkill
- navigationSkill
- overlaysSkill
- page-transitionsSkill
- paymentsSkill
- physicsSkill
- previewSkill
- pricingSkill
- print-craftSkill
- product-detailSkill
- retrofitSkill
- routingSkill
- The first 60 shown.
The file
Files
component-api — one dialect, ten components
Stage: Phase 3 — Foundation (after tokens, before the component tier) - Reads: design/SYSTEM.md, lib/utils.ts (cn) - Writes: no file of its own — the shared prop contract every components/ui/* and section component honors (a reference skill, like taste)
Standard
A site reads as assembled when each component is individually fine but they speak ten prop dialects — variant="primary" here, type="filled" there, isLarge next to size="lg", a bespoke as="a" beside a real asChild. Close inspection catches the seam even when no single component is wrong. First-grade means the opposite: every component is configured the same way, so a developer who has used one has used all of them, and the system reads as one author's work. This is a design-system discipline orthogonal to any component's visual spec — ultraweb:buttons owns what a button looks like; this skill owns how you configure it. It governs; it ships no file. Every component-tier skill obeys it, and ultraweb:gate-code greps for its violations.
The contract
Eight rules. A component may use only the axes it needs, but the ones it uses obey these names and shapes.
- The vocabulary is exactly three axes:
variant,size,tone.variant= the form/weight the component takes (button: primary/secondary/ghost; card: media/stat/editorial).size= the scale step, shared meaning site-wide (sm/md/lg/xl).tone= semantic intent that selects a token family (default→ foreground/muted,brand→ primary,danger→ destructive,success/warning→ status tokens). No synonyms, ever — nevertype,kind,color,appearance,emphasis,intent, orscale. Status-bearing components (badge, alert, toast, input error) express intent throughtone; a component whose destruction is a distinct filled treatment (the Button) may legitimately carrydestructiveas avariant— but the name of every axis is fixed. - Variants are
cva()enums that resolve to tokens, never literals. Eachvariant/size/tonevalue is a row in onecva()map whose classes are token-backed utilities (bg-primary,text-sm,rounded-md,shadow-md) with adefaultVariantsfor the rest state. A hex, a bareoklch(, or an arbitrarybg-[…]inside a variant row is a defect — the value you reached for is a tokenultraweb:tokensalready owns. This is where "variants map to the design system" is enforced, not merely intended. cn()is the only class merge, andclassNamecomes last.cn(clsx + tailwind-merge, fromlib/utils.ts) is the single merge path:cn(buttonVariants({ variant, size }), className). The consumer'sclassNameis the final argument so tailwind-merge lets a caller override a token utility (rounded-none,w-full) without specificity wars or!important. Never string-concatenate classes with+or template literals; never putclassNamebefore the variants.- Polymorphism is
asChild(RadixSlot) — never a customasprop. When a component must render as a different element — a CTA that is anext/link, a card that is one big link — it acceptsasChildand renders<Slot>, which merges its classes and props onto the caller's single child. Noas="a"string, nocomponent={Link}prop: those discard the child element's real types and its native props. - Every root carries
data-slot="<component>[-<part>]"; target parts by data-slot. The shadcn/React-19 hook for styling, state, and tests. Group styling and state variants selectdata-[slot=…],group-data-[state=open],has-[[data-slot=icon]]— never fragile child combinators (> div > span). - Refs are plain props (React 19) — no
forwardRef; spread...propsonto the root.function Button({ ref, className, ...props }). Spreading...propslast-but-one (beforeclassNameis applied viacn) forwards every native attribute —type,disabled,onClick,id,name— and everyaria-*/rolefor free. Native-attribute forwarding and a11y pass-through are the same rule: don't enumerate props you could spread. - Stateful components support controlled and uncontrolled, one pattern. Anything with internal state (tabs, accordion, dialog, switch) accepts
value/defaultValue(oropen/defaultOpen) +onValueChange; controlled when the value prop is present, uncontrolled otherwise. This is Radix's own contract — restyle the Radix primitive, never re-implement its state machine as a third mode. - Compound components share state via context; sub-parts are
X.Header/X.Body. A multi-part component (Card, Field) exports a namespace where each part carries its owndata-slotand shared config flows through a tiny context — not prop-drilling, not one giant props object. Callers compose the parts; the component owns the wiring.
Three composition shapes, in order of reach-for: the variant enum (rule 2) is the default closed set and covers ~90% of configuration; asChild/Slot (rule 4) handles element swaps; a render-prop escape hatch (children as a function receiving state — Base-UI style) is the last resort, only when a caller must inject arbitrary markup a closed variant can't express. Reach left before right.
Anti-patterns
as="a"/component={…}string-polymorphism props — useasChild+Slot(rule 4).type=,kind=,appearance=,color=,emphasis=,intent=,scale=as prop names — synonyms of the canonical trio; rename tovariant/size/tone.- Boolean soup —
isPrimary,isLarge,outlined,filled,dangerbooleans instead of enum axes. Two booleans that can't both be true are onevariant. forwardRef(in a new component file — React 19 passesrefas a prop; grep for it, treat a hit as a relic.classNamemerged with+or a template literal, or placed before the variants incn()— the caller can no longer override.- A hex, bare
oklch(, orbg-[…]/text-[…]inside acva()variant row — defer to a token (ultraweb:tokens). - Child-combinator selectors (
.card > div) instead ofdata-[slot=…]targeting. - Re-implementing a Radix stateful primitive's controlled/uncontrolled logic by hand instead of restyling it.
- Per-call-site
classNamesoup faking a variant that should live in the sharedcva()map — the single loudest "assembled, not authored" tell.
Worked example — Tidepool, port-logistics SaaS (Precision Instrument — Neo-grotesque Minimal)
Moved to references/example.md — read only when this build's case is genuinely ambiguous; the sections above are the decision material.
Composes with
Moved to references/composes.md — the handoff map; load it when orchestrating this skill against its neighbors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

