react-styled-components-cursorrules-prompt-file — Cursor rule
A Cursor rule that tells the agent how to write React code with styled-components: functional components, theming through ThemeProvider, a fixed folder layout.
.cursor/rules/react-styled-components-cursorrules-prompt-file.mdcWhat react-styled-components-cursorrules-prompt-file does
The file spells out how React code should look in your project. The agent gets a set of instructions: functional components with hooks, reusable styled components, dynamic styling through props, the css helper when it fits. A folder structure is included too — src/components/styled, src/styles with theme.js and globalStyles.js, plus pages and utils.
A second list covers naming like StyledButton, one consistent theming system, CSS-in-JS for all styling, the attrs method for props you repeat often, TypeScript support and the css prop for conditional styles. Everything sits in a single markdown file. No scripts, no packages pulled in.
The rule ships with alwaysApply: false and globs set to **/*, so it stays off until you enable it or point the agent at it in a prompt. If your project styles things with CSS modules or Tailwind, the CSS-in-JS instructions will fight the existing code — worth checking what you already use before dropping this in.
What it helps with
- set one code style for React components across the project
- agree on a folder layout for styles and theme files
- move styling to styled-components without naming drift
- wire up ThemeProvider and shared global styles
- define conventions for dynamic props and the
cssprop
Example prompts for the agent
- Create a button component following the react-styled-components rule, with styles in
src/components/styled - Set up ThemeProvider and
globalStyles.jsinsrc/stylesthe way the rule describes - Refactor this component to styled-components with dynamic styling via props
How to install react-styled-components-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/react-styled-components-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/react-styled-components-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-styled-components-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-styled-components-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/react-styled-components-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about react-styled-components-cursorrules-prompt-file
How do I install react-styled-components-cursorrules-prompt-file in Cursor?
Copy the rule file to .cursor/rules/react-styled-components-cursorrules-prompt-file.mdc in your project root. It then shows up in the rules list, where you can switch it on.
What does react-styled-components-cursorrules-prompt-file do?
It gives the Cursor agent rules for React code with styled-components: functional components, theming via ThemeProvider, reusable styled components, and a folder layout of src/components/styled and src/styles.
Does the rule apply to every file automatically?
No. It has alwaysApply: false, so it does not turn itself on — you enable it manually or reference it in a prompt.
Source text
react-styled-components-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for React development with Styled Components integration."
globs: **/*
alwaysApply: false
---
// React + Styled Components .cursorrules
// Prefer functional components with hooks
const preferFunctionalComponents = true;
// Styled Components best practices
const styledComponentsBestPractices = [
"Use the styled-components/macro for better debugging",
"Implement a global theme using ThemeProvider",
"Create reusable styled components",
"Use props for dynamic styling",
"Utilize CSS helper functions like css`` when needed",
];
// Folder structure
const folderStructure = `
src/
components/
styled/
styles/
theme.js
globalStyles.js
pages/
utils/
`;
// Additional instructions
const additionalInstructions = `
1. Use proper naming conventions for styled components (e.g., StyledButton)
2. Implement a consistent theming system
3. Use CSS-in-JS for all styling needs
4. Utilize styled-components' attrs method for frequently used props
5. Implement proper TypeScript support for styled-components
6. Use the css prop for conditional styling when appropriate
7. Follow the styled-components documentation for best practices
`;
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules