UI component & docs
Build and maintain shared UI primitives in packages/ui (shadcn-style, owned in-repo) and their docs pages in the FrontDesk UI Studio. Scope: primitives in packages/ui/src/components/*.tsx — not blocks/ or app-level components.
Two deliverables, always together: the component and its docs page. A component without a docs page is incomplete.
Before writing
- Read 2-3 neighboring components to match current conventions —
button.tsx(cva + forwardRef + Base UI),card.tsx(compound,data-slot),composite.tsx(context +useRender). New components are Base UI only (@base-ui/react) — never add Radix, even where older components use it. - Skim REFERENCE.md for the styling tokens and rules.
- For edits: find the component's existing docs route and update it in lockstep.
Build the component
Start from templates/component.tsx. Then verify against REFERENCE.md:
- [ ] Built on
@base-ui/react(oruseRenderfor a from-scratch element) +cvavariants, withdefaultVariants. No Radix /Slot/asChild. - [ ] Composable, not monolithic (enforced — see REFERENCE.md): structure split into named sub-components/slots, not content props; element substitution via the Base UI
renderprop; shared state via context, not a fixed child order. If you reach for a 3rd boolean or a*Content/*Iconprop, stop and compose instead. - [ ]
data-sloton every rendered element. - [ ]
className,ref, and...propsforwarded to the DOM node on every part (classNamethroughcn(), last). Nothing intercepted. - [ ] Styled only with brand tokens (
bg-background-*,text-foreground-*, focus/invalid rings). No raw hex except the primary blue#345BCA. - [ ] Exports the component and its
xVariants. - [ ] Accessible: keyboard, focus ring,
aria-*, labels for icon-only.
Build the docs page
Read DOCS_TEMPLATE.md (the format spec) and start from templates/docs-page.tsx.
- Ensure the doc kit exists. If
packages/ui/src/routes/-components/doc-kit.tsxis missing, create it from templates/doc-kit.tsx. Otherwise reuse it. - Create
packages/ui/src/routes/<name>.tsxfollowing the fixed structure:metaexport →DocPage→ Demo sections →PropsTable→Anatomy(compound only).
- [ ]
metais complete and accurate — an agent can understand the component from it alone (status, import, when to use / not, related). - [ ] Every
<Demo>codeprop is the exact JSX it renders (no drift). - [ ]
PropsTablemirrors the real variants/props.
- Register it in
routes/-components/sidebar.tsxunder the Components group (newSidebarMenuItem,data-activeon the pathname,<Link to="/<name>">). The page is unreachable until linked.
Finish
- [ ] Typecheck:
bun run --filter @workspace/ui typecheck. Fix any errors. - [ ] Summarize what changed (component variants + that the docs page and sidebar link were added/updated).
Mention the user can preview at the UI Studio with bun run --filter @workspace/ui ui:dev.