Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

styled-components-emotion

/styled-components-emotion

Porządkuje style komponentów w styled-components lub Emotion, z dynamicznymi motywami i abstrakcjami CSS-in-JS.

Licencja
MIT
Ostatnia zmiana repozytorium
28.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 28.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Porządkuje style komponentów w styled-components lub Emotion, z dynamicznymi motywami i abstrakcjami CSS-in-JS.

Oryginalny opis (EN)

Use this skill when managing component-scoped styles, dynamic theme props, and CSS-in-JS abstractions using styled-components or Emotion.

Jak działa

  1. When to use
  2. Prerequisites
  3. Step-by-step workflow
  4. Commands / code examples
  5. Common mistakes & pitfalls
  6. Verification checklist
  7. Related skills
Sekcje z nagłówków SKILL.md, w oryginale · 71 linii, 354 słów
Podgląd SKILL.md
---
name: styled-components-emotion
description: Use this skill when managing component-scoped styles, dynamic theme props, and CSS-in-JS abstractions using styled-components or Emotion.
---
# Styled Components and Emotion

## When to use
Use this skill when developing design systems and dynamic React applications requiring runtime theme switching, prop-driven styling, and CSS-in-JS encapsulation.

## Prerequisites
- Node.js 18+ and `styled-components` or `@emotion/react` / `@emotion/styled` installed.
- Babel/SWC plugins configured for server-side rendering (SSR) style extraction.

## Step-by-step workflow
1. **Configure SSR style registry**: Ensure the server-side style sheet collector (e.g., `ServerStyleSheet` or Emotion Cache) injects styles on SSR passes.
2. **Define ThemeProvider**: Wrap root component with `ThemeProvider` delivering strongly typed design tokens.
3. **Author styled primitives**: Create styled tags with tagged template literals or object styles utilizing prop interpolation.
4. **Extend existing components**: Apply `styled(ExistingComponent)` to wrap and augment third-party or custom components with new styles.
5. **Optimize runtime rendering**: Extract static style declarations outside render functions to avoid recreating component definitions every frame.

## Commands / code examples
```tsx
import styled from 'styled-components';

interface ButtonProps {
  $variant?: 'primary' | 'danger';
  $fullWidth?: boolean;
}

export const StyledButton = styled.button<ButtonProps>`
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: ${(props) => props.theme.radii.md};
  font-weight: 600;
  width: ${(props) => (props.$fullWidth ? '100%' : 'auto')};
  transition: opacity 0.2s ease;

  background-color: ${(props) =>
    props.$variant === 'danger'
      ? props.theme.colors.danger
      : props.theme.colors.primary};
  color: #ffffff;
  border: none;
  cursor: pointer;

  &:hover {
    opacity: 0.9;
  }

  &:focus-visible {
    outline: 2px solid ${(props) => props.theme.colors.focus};
    outline-offset: 2px;
  }
`;
```

## Common mistakes & pitfalls
- Defining styled components inside a React component render function, causing recreation and loss of input focus on every re-render.
- Passing raw props directly to the DOM without using transient props (prefixed with `$`), causing invalid HTML attribute warnings.
- Missing SSR style extraction setup, leading to Flash of Unstyled Content (FOUC).

## Verification checklist
- [ ] Styled components are defined at file-level scope outside render functions.
- [ ] Transient props (`$propName`) prevent custom styling props from leaking into DOM attributes.
- [ ] Design tokens are accessed via `theme` context rather than hardcoded hex values.
- [ ] SSR style hydration produces zero FOUC on initial page load.

## Related skills
- react-fundamentals
- react-state-management
- css-modules-and-sass
- tailwindcss-architecture

Wersje

W bazie nie ma innych skilli o nazwie styled-components-emotion.

Migawka bazy z 13.11.2026 · wersja paczki 76dffde82747 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95emotion-migrate
    Migruje styled-components z Emotion do komponentów Mantine ze style props i modułami CSS, przy konwersji plików .styled.tsx i usuwaniu importów @emotion.
  • 100devup-ui
    Pomaga wdrożyć bibliotekę Devup UI, czyli CSS-in-JS bez narzutu w runtime, z konfiguracją motywu i migracją ze styled-components.
  • 100css-ninja
    Pomaga w CSS z Tailwind, CSS-in-JS, układami responsywnymi, animacjami i trybem ciemnym: Grid, Flexbox, styled-components, emotion i architektura BEM lub utility-first.
  • 100styled-components-helper
    Wspiera pracę ze styled-components w ramach automatycznie aktywowanej kategorii Frontend Development, reagując na frazy związane z pomocnikiem styled components.
  • 90frontend-css-strategy
    Dobiera podejście do CSS, np. moduły, CSS-in-JS czy Tailwind, według wielkości projektu, zespołu i wydajności.
  • 100migrate-styled-components-to-vanilla-extract
    Prowadzi krok po kroku migrację projektu ze styled-components do vanilla-extract, w tym pliki .css.ts, usunięcie zależności i eksport ./bundle.css.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.