Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/react-styled-components-cursorrules-prompt-file.mdc
Open on GitHub

What 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 css prop

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.js in src/styles the 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.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set68

salesforce-apex-cursorrules-prompt-file A Cursor rule that points the agent at Salesforce Apex work: queueables instead of @future, GoF patterns, and almost no comments. ★ 41,011repo stars rtl-right-to-left-i18n-cursorrules-prompt-file A Cursor rule that pushes the agent toward logical CSS and Tailwind utilities instead of left/right. Useful when the app has to run in Arabic, Hebrew, Persian or Urdu. ★ 41,011repo stars react This rule hands Cursor a set of React conventions: component structure, hooks, state, forms and accessibility. Useful when a project has plenty of .tsx and .jsx and you want one style. ★ 41,011repo stars react-typescript-nextjs-nodejs-cursorrules-prompt- A Cursor rule that pins down React, TypeScript, Next.js 14 and Node.js conventions: functional components, RORO, minimal use client. ★ 41,011repo stars react-query-cursorrules-prompt-file A Cursor rule that tells the agent how to write React Query code: where QueryClient lives, how hooks and query keys are named. ★ 41,011repo stars react-native-expo-cursorrules-prompt-file A Cursor rule that tells the agent how to write React Native code with Expo. Useful when you want new screens and components to follow one stack. ★ 41,011repo stars rails-cursorrules-prompt-file A Cursor rule file that tells the agent how to write Rails 8 code: generators, bin/dev, the Solid stack, Minitest and Hotwire. ★ 41,011repo stars qwik-basic-cursorrules-prompt-file A Cursor rule that sets Qwik conventions for the agent: lazy functions with the $ suffix, signals, tasks, and a TypeScript plus Vite project layout. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor