React component development in Core
Core runs React 19 (react in package.json). Shared components live in packages/ui; read packages/ui/AGENTS.md before adding or changing one, and use the moai-library-shadcn and base-ui skills for shadcn and primitive work.
Rules
- Composition over configuration: Prefer
childrenand named parts (Card,CardHeader,CardTitle) over many boolean props. - Refs are props: In React 19, a function component receives
refas a prop. Type props withReact.ComponentProps<"element">and spread them; do not addforwardRefto new components. - Base UI composition: Use the
renderprop for polymorphism; never RadixasChild. - Styling: Merge classes with
cnfrom@asym/ui/lib/utils, express variants with CVA, and use semantic tokens (bg-card,text-muted-foreground) rather than raw palette colors. The design-system lint enforces this. - Accessibility: Use semantic HTML first; add ARIA only when needed (
accessibility-review). - Predictable props: Follow controlled/uncontrolled conventions; extract complex behavior into hooks.
- Ownership: Reusable components belong in
packages/ui; apps compose them and do not fork them.
Checklist
- [ ] Single responsibility; small, composable API
- [ ] Props typed from
React.ComponentProps, spread onto the DOM element; no newforwardRef - [ ]
data-slot,cn, CVA, and semantic tokens follow neighboring components - [ ] Semantic HTML and keyboard interaction work
- [ ] Shared components live in
packages/ui
Example
Shared components follow this shape (see packages/ui/components/shadcn/card.tsx):
import * as React from "react";
import { cn } from "@asym/ui/lib/utils";
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground rounded-xl border",
className,
)}
{...props}
/>
);
}