Styled components

From oyi77/1ai-skills · View interactive version

Styled components is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when styled-components CSS-in-JS — tagged templates, theming, props, animations, SSR, performance.

How to use this skill

Skill file

Overview

styled-components enables CSS-in-JS with tagged template literals. Components are styled directly in JavaScript with access to props, themes, and dynamic values. Supports SSR and tree-shaking.

Capabilities

When to Use

Trigger phrases:

When NOT to Use

Pseudo Code

The styled-components workflow follows a standard pipeline pattern.

Core flow:

# styled-components primary flow
input = prepare(raw_data)
result = process(input, config={animations, components, performance, props, styled})
validate(result)
deliver(result)

Error handling:

on error:
  log(error_details)
  retry_with_backoff(max=3)
  if still_failing: alert_and_escalate()

Core Workflow

# styled-components primary flow
input = prepare(raw_data)
result = process(input, config={animations, components, performance, props, styled})
validate(result)
deliver(result)

Error Handling

on error:
  log(error_details)
  retry_with_backoff(max=3)
  if still_failing: alert_and_escalate()

Basic Usage

import styled from "styled-components"

const Button = styled.button`
  background: ${(props) => props.$primary ? "#3b82f6" : "#e5e7eb"};
  color: ${(props) => props.$primary ? "white" : "#374151"};
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  &:hover { opacity: 0.9; }
`

// Usage: <Button $primary>Click</Button>

Theme Provider

import { ThemeProvider } from "styled-components"

const theme = {
  colors: {
    primary: "#3b82f6",
    background: "#ffffff",
    text: "#1f2937",
  },
  spacing: { sm: "8px", md: "16px", lg: "24px" },
}

function App() {
  return (
    <ThemeProvider theme={theme}>
      <MyApp />
    </ThemeProvider>
  )
}

Theme Access

const Card = styled.div`
  background: ${({ theme }) => theme.colors.background};
  padding: ${({ theme }) => theme.spacing.md};
  color: ${({ theme }) => theme.colors.text};
`

Extending Components

const PrimaryButton = styled(Button)`
  background: #3b82f6;
  color: white;
  font-weight: 600;
`

Keyframes

import { keyframes } from "styled-components"

const fadeIn = keyframes`
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
`

const AnimatedDiv = styled.div`
  animation: ${fadeIn} 0.3s ease-out;
`

Common Patterns

How to Use

  1. Define content goal (traffic, engagement, conversion, brand awareness)
  2. Research target audience pain points and search intent
  3. Generate content using appropriate AI tools
  4. Edit and humanize output for authenticity
  5. Optimize for target platform (SEO, hashtags, format)
  6. Schedule and distribute across channels
  7. Measure performance and iterate

Red Flags

Verification

Process

  1. Analyze the task requirements
  2. Apply domain expertise
  3. Verify output quality

Anti-Rationalization Table

| Rationalization | Reality |

|---|---|

| "Good enough content works" | Quality content drives engagement. Mediocre content gets ignored. |

| "I will optimize later" | SEO and distribution need optimization from the start. |

| "Templates are good enough" | Templates are a starting point. Custom content outperforms generic. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.