We strongly recommend configuring your AI Agent with the following recommended Agent guidelines and MCPs. This will give your AI Agent context about the registry so it can make informed decisions when building UIs.
We strongly recommend you add these code style guidelines to your agent, as it ensures proper UI best practices are followed every time you want to build a UI.
Create a .cursor/rules/ui.md file and paste the following code:
.cursor/rules/ui.md
---name: Redpanda UI Registrywhen: Whenever a user wants to build a UI or requests code examples or documentation for the Redpanda UI Registry (or design system or UI library)actions:- mcp: use context7 /websites/redpanda-ui-registry_netlify_app---# UI Development GuideThis document provides agent-optimized instructions for building user interfaces in this repository.## Activation ConditionsApply these instructions when the user request includes ANY of:- Building/creating/implementing UI components or pages- Keywords: "design system", "ui", "frontend", "registry", "component"- Requesting code examples or documentation for UI components- Modifying existing UI that uses registry components## Critical Rules### ALWAYS- Use Redpanda UI Registry components from `./src/components/redpanda-ui` (check `cli.json` for exact path)- Invoke MCP tool `mcp__context7__get-library-docs` with library ID `/websites/redpanda-ui-registry_netlify_app` BEFORE writing UI code- Use functional React components (never class-based)- Install components using the CLI from registry documentation- Create unit tests following this repository's testing patterns- Use TypeScript with strict typing (infer types, never use `any`)### NEVER- Use `@redpanda-data/ui` library (deprecated)- Modify files in the registry base directory (specified in `cli.json` `baseDir`)- Copy/paste registry source code (always install via CLI)- Install external UI libraries (unless explicitly requested by user)- Use inline `style` prop on registry components- Add `className` margins directly to registry components- Leave `console.log` or TODO comments in production code## Workflow### 1. Fetch Documentation```REQUIRED FIRST STEP: Invoke mcp__context7__get-library-docs- library ID: /websites/redpanda-ui-registry_netlify_app- Include relevant topic if known (e.g., "buttons", "forms", "layout")```### 2. Component Planning- Identify required registry components from documentation- Check if components already exist in `./src/components/redpanda-ui`- Plan component composition and data flow### 3. Install Components```bash# Single componentyes | bunx @fumadocs/cli add --dir https://redpanda-ui-registry.netlify.app/r <component-name># Multiple components (space-separated)yes | bunx @fumadocs/cli add --dir https://redpanda-ui-registry.netlify.app/r card accordion calendar```**If CLI fails to install dependencies:**- Manually install missing dependencies- Check registry documentation for dependency list### 4. Write Component CodeApply these standards:**Component Structure:**- Use functional components with hooks- Export named components (not default exports unless required)- Use `forwardRef` when component needs ref forwarding- Prefer fragments over unnecessary wrapper divs**TypeScript:**- Define explicit prop interfaces- Infer return types (don't annotate unnecessarily)- Use proper generic types for collections- Never cast to `any` - deduce correct types**Styling:**- Use Tailwind utility classes via `className`- Leverage registry component variants and props (not custom `className` overrides)- Wrap registry components in divs for spacing (don't add margin classes directly)- Ensure responsive design with Tailwind breakpoints**Performance:**- Hoist static content outside component body- Use `useMemo` for expensive computations- Wrap components receiving props with `memo` when appropriate- Avoid unnecessary re-renders**Accessibility:**- Include proper ARIA labels and roles- Ensure keyboard navigation support- Use semantic HTML elements- Test with screen reader considerations### 5. Create Tests- Follow repository's testing patterns (check `vitest.config.*.mts`)- Test component rendering and user interactions- Mock API calls and external dependencies- Achieve meaningful coverage of business logic### 6. Validation ChecklistRun these commands in order:```bash# 1. Type checkingbun run type:check# 2. Run testsbun run test# 3. Lint codebun run lint# 4. Build applicationbun run build# 5. Start dev server (check for runtime errors)bun run start```**Success Criteria:**- ✓ All TypeScript errors resolved- ✓ All tests passing- ✓ No lint errors- ✓ Build completes without errors- ✓ Dev server runs without console errors- ✓ UI renders correctly in browser### 7. End-to-End Tests (Optional)If repository has Playwright installed:- Ask user if they want E2E tests created- Follow repository's E2E testing patterns## Component Development Patterns### Reusable Sub-ComponentsWhen logic or UI repeats within a feature:- Create sub-components in the same file- Keep related code colocated- Use composition over prop drilling### Example Structure```typescript// Main feature componentexport function FeatureComponent() { return ( <div> <FeatureHeader /> <FeatureContent /> <FeatureActions /> </div> );}// Colocated sub-componentsfunction FeatureHeader() { /* ... */ }function FeatureContent() { /* ... */ }function FeatureActions() { /* ... */ }```### Registry Component Usage```typescript// ✓ CORRECT: Use variants and component props<Button variant="primary" size="lg"> Click Me</Button>// ✗ WRONG: Custom className overrides<Button className="bg-blue-500 px-8"> Click Me</Button>// ✓ CORRECT: Wrap for spacing<div className="mt-4"> <Button variant="primary">Click Me</Button></div>// ✗ WRONG: Direct margin on component<Button className="mt-4" variant="primary"> Click Me</Button>```## Quick Reference### When to Install from Registry- User needs a button, form, card, dialog, etc.- User asks about UI/design system capabilities- Building new feature with visual components### When to Check Existing Components- Before installing, check `./src/components/redpanda-ui`- Review `cli.json` for configured base directory- Search codebase for similar patterns### Multi-Component Installation Pattern```bashyes | bunx @fumadocs/cli add --dir https://redpanda-ui-registry.netlify.app/r button card dialog form input```### Testing Command Reference```bashbun run test # All testsbun run test:unit # Unit tests onlybun run test:integration # Integration tests onlybun run test:watch # Watch mode with UIbun run test:coverage # Coverage report```