react-components-creation-cursorrules-prompt-file — Cursor rule
Guides React component creation in Cursor by checking for duplicates, building v0.dev generation links, and standardising shadcn/ui imports.
.cursor/rules/react-components-creation-cursorrules-prompt-file.mdcWhat react-components-creation-cursorrules-prompt-file does
This rule sets up a structured routine for creating TypeScript and Tailwind CSS UI components. Cursor inspects packages/ui/src/components and apps/spa/src/components first to avoid rebuilding components that already exist.
When a new component is needed, the assistant crafts a prompt outlining props, styling, and behavior. It URL-encodes this text into a clickable v0.dev link. Once generated, the code is adapted to project conventions, wiring shadcn/ui imports to @repo/ui/components/ui/ and local imports to @/components.
The workflow assumes a monorepo setup. Leaving placeholders like <ui_package_alias> and <app_package_alias> unedited breaks imports immediately.
What it helps with
- detect existing UI components in monorepo packages before coding
- compile detailed prompts and clickable links for v0.dev UI generation
- align generated component imports with shadcn/ui and local project aliases
Example prompts for the agent
- Create a date range picker component for our SPA app
- Build an analytics summary card using TypeScript and Tailwind CSS
How to install react-components-creation-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/react-components-creation-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/react-components-creation-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/react-components-creation-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/react-components-creation-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/react-components-creation-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about react-components-creation-cursorrules-prompt-file
How to install react-components-creation-cursorrules-prompt-file in Cursor?
Save the rule file to .cursor/rules/react-components-creation-cursorrules-prompt-file.mdc.
Why does the rule generate a v0.dev URL?
It builds an encoded prompt link so you can draft UI on v0.dev before bringing the code back into your repository.
Which directories does this rule check for existing components?
It searches packages/ui/src/components and apps/spa/src/components before prompting for a new component.
Source text
react-components-creation-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for React component creation and development."
globs: **/*
alwaysApply: false
---
# Cursor Rules
## Whenever you need a React component
1. Carefully consider the component's purpose, functionality, and design
2. Think slowly, step by step, and outline your reasoning
3. Check if a similar component already exists in any of the following locations
1. packages/ui/src/components
2. apps/spa/src/components
4. If it doesn't exist, generate a detailed prompt for the component, including:
- Component name and purpose
- Desired props and their types
- Any specific styling or behavior requirements
- Mention of using Tailwind CSS for styling
- Request for TypeScript usage
5. URL encode the prompt.
6. Create a clickable link in this format:
[ComponentName](https://v0.dev/chat?q={encoded_prompt})
7. After generating, adapt the component to fit our project structure:
- Import
- common shadcn/ui components from <ui_package_alias>@repo/ui/components/ui/</ui_package_alias>
- app specific components from <app_package_alias>@/components</app_package_alias>
- Ensure it follows our existing component patterns
- Add any necessary custom logic or state management
Example prompt template:
"Create a React component named {ComponentName} using TypeScript and Tailwind CSS. It should {description of functionality}. Props should include {list of props with types}. The component should {any specific styling or behavior notes}. Please provide the full component code."
Remember to replace placeholders like <ui_package_path> and <app_package_alias> with the actual values used in your project.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules