react styled components
via PatrickJS/awesome-cursorrules
React development with Styled Components integration and best practices.
What is react styled components?
This rule guides React development using Styled Components for CSS-in-JS styling. It establishes conventions for functional components with hooks, theming with ThemeProvider, and a structured folder layout. Use it to maintain consistency when building styled React applications.
- Enforces functional components with React hooks
- Provides Styled Components best practices including macro imports and global theming
- Defines folder structure for components, styles, and theme organization
- Recommends naming conventions for styled components (e.g., StyledButton)
- Guides TypeScript support and dynamic styling with props
- Suggests using attrs method and css helper functions for advanced patterns
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
// 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 = `
- Use proper naming conventions for styled components (e.g., StyledButton)
- Implement a consistent theming system
- Use CSS-in-JS for all styling needs
- Utilize styled-components' attrs method for frequently used props
- Implement proper TypeScript support for styled-components
- Use the css prop for conditional styling when appropriate
- Follow the styled-components documentation for best practices `;
Related rules
Zero-loading-spinner React SPA with TanStack Router v1 + TanStack Query v5 for type-safe URLs and cache-first data.
Zero-loading-spinner routing with TanStack Router v1 and Query v5 for type-safe React SPAs
Expert guidance for React, TypeScript, Next.js 14, and Web3 stack development with Wagmi and Viem.
Full-stack React, TypeScript, and Symfony development assistant with Docker expertise.
React and TypeScript state management guidance for Zustand stores, selectors, middleware, persistence, and testing.
Write READMEs that convert readers in 3-5 seconds with landing-page structure and working code examples.
