styled-components vs styled-system vs emotion vs theme-ui
CSS-in-JS Kütüphaneleri
styled-componentsstyled-systememotiontheme-uiSimilar Packages:

CSS-in-JS Kütüphaneleri

CSS-in-JS kütüphaneleri, JavaScript kodu içinde stil tanımlamayı sağlayarak bileşen tabanlı geliştirmeyi kolaylaştırır. Bu kütüphaneler, stilin bileşenle birlikte tanımlanmasına olanak tanır, böylece stil ve işlevsellik arasında daha iyi bir entegrasyon sağlanır. Ayrıca, dinamik stiller oluşturmayı ve bileşenlerin yeniden kullanılabilirliğini artırmayı mümkün kılar.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
styled-components14,938,96241,0472.18 MB2225 days agoMIT
styled-system1,139,003---7 years agoMIT
emotion981,595---6 years agoMIT
theme-ui77,0645,40880.4 kB6110 months agoMIT

Feature Comparison: styled-components vs styled-system vs emotion vs theme-ui

Performans

  • styled-components:

    Styled-components, stil tanımlama sürecinde performansı optimize eder. Ancak, büyük projelerde stil dosyalarının yönetimi karmaşık hale gelebilir, bu nedenle dikkatli bir yapılandırma gerektirir.

  • styled-system:

    Styled-system, stil uygulamalarını optimize ederek performansı artırır. Responsive tasarım özellikleri sayesinde, yalnızca gerekli stiller yüklenir ve uygulanır, bu da performansı olumlu yönde etkiler.

  • emotion:

    Emotion, stil tanımlama ve uygulama konusunda yüksek performans sunar. Dinamik stiller oluşturma yeteneği ile birlikte, stilin yalnızca gerekli olduğunda uygulanmasını sağlar, bu da gereksiz yeniden render işlemlerini azaltır.

  • theme-ui:

    Theme-ui, tema tabanlı bir yapı sunduğu için performansı artırır. Temalar arasında geçiş yaparken, yalnızca gerekli stiller uygulanır, bu da performansın korunmasına yardımcı olur.

Esneklik

  • styled-components:

    Styled-components, bileşen tabanlı bir yaklaşım sunduğu için esneklik sağlar. Ancak, stil tanımlama sürecinde belirli kurallar ve yapılar izlenmelidir.

  • styled-system:

    Styled-system, responsive ve tema tabanlı tasarımlar oluşturma konusunda esneklik sunar. Özellikle tasarım sistemleri ile entegre çalışabilme yeteneği, geliştiricilere büyük avantaj sağlar.

  • emotion:

    Emotion, geliştiricilere stil tanımlama konusunda büyük bir esneklik sunar. CSS ve JavaScript'in birleşimi sayesinde, dinamik ve karmaşık stiller oluşturmak mümkündür.

  • theme-ui:

    Theme-ui, tema yönetimi konusunda esneklik sunar. Temalar arasında kolayca geçiş yaparak, uygulamanın genel görünümünü değiştirmek mümkündür.

Öğrenme Eğrisi

  • styled-components:

    Styled-components, bileşen tabanlı stil yazımını öğrenmek için biraz zaman alabilir. Ancak, bileşenler arası stil paylaşımı ve yönetimi konusunda güçlü bir yapı sunar.

  • styled-system:

    Styled-system, responsive tasarım ve tema yönetimi konularında öğrenme eğrisi sunabilir. Ancak, bir kez anlaşıldığında, güçlü bir araç haline gelir.

  • emotion:

    Emotion, öğrenmesi oldukça kolay bir kütüphanedir. CSS ve JavaScript bilgisi olan geliştiriciler için hızlı bir başlangıç sunar.

  • theme-ui:

    Theme-ui, basit bir API sunduğu için öğrenmesi kolaydır. Temel kavramları hızlı bir şekilde kavrayarak, projelerde etkili bir şekilde kullanılabilir.

Tema Yönetimi

  • styled-components:

    Styled-components, tema yönetimi için güçlü bir yapı sunar. Temalar, bileşenler arasında kolayca paylaşılabilir ve uygulanabilir.

  • styled-system:

    Styled-system, tema yönetimi konusunda en iyi seçeneklerden biridir. Responsive tasarım ve tema tabanlı stil uygulamaları için optimize edilmiştir.

  • emotion:

    Emotion, tema yönetimi konusunda esneklik sağlar. Ancak, tema oluşturma ve yönetme süreci, geliştiricinin tercihlerine bağlı olarak değişebilir.

  • theme-ui:

    Theme-ui, tema yönetimini basit ve etkili bir şekilde sağlar. Temalar arasında geçiş yaparak, uygulamanın görünümünü hızlı bir şekilde değiştirmek mümkündür.

Kullanım Senaryoları

  • styled-components:

    Styled-components, bileşen tabanlı projelerde ve UI kütüphanelerinde yaygın olarak kullanılır. Proje büyüdükçe stil yönetimini kolaylaştırır.

  • styled-system:

    Styled-system, tasarım sistemleri ve responsive uygulamalar için mükemmel bir seçimdir. Özellikle UI bileşenleri oluştururken büyük avantaj sağlar.

  • emotion:

    Emotion, dinamik ve karmaşık stiller gerektiren projelerde idealdir. Özellikle performansın kritik olduğu uygulamalarda tercih edilmelidir.

  • theme-ui:

    Theme-ui, basit ve etkili tema yönetimi gerektiren projelerde kullanılır. React tabanlı uygulamalarda tema uygulamak için idealdir.

How to Choose: styled-components vs styled-system vs emotion vs theme-ui

  • styled-components:

    Styled-components, bileşen tabanlı stil yazımını tercih eden ve stilin bileşenle birlikte tanımlanmasını isteyen geliştiriciler için uygundur. Proje büyüdükçe stil yönetimini kolaylaştırmak için kullanılabilir.

  • styled-system:

    Styled-system, responsive ve tema tabanlı tasarımlar oluşturmak isteyen geliştiriciler için mükemmel bir seçimdir. Özellikle tasarım sistemleri ve UI bileşenleri için esneklik arayan projelerde tercih edilmelidir.

  • emotion:

    Emotion, yüksek performans ve esneklik arayan geliştiriciler için idealdir. Özellikle CSS-in-JS yaklaşımını benimseyen ve stil yönetiminde daha fazla kontrol isteyen projelerde tercih edilmelidir.

  • theme-ui:

    Theme-ui, tema yönetimi ve stil oluşturma konusunda basitlik arayan geliştiriciler için idealdir. Özellikle React tabanlı projelerde, tema yönetimi ve stil uygulamasını kolaylaştırmak için kullanılabilir.

README for styled-components


Fast, expressive styling for React.
Server components, client components, streaming SSR, React Native—one API.

npm downloads gzip size

styled-components is largely maintained by one person. Please help fund the project for consistent long-term support and updates: Open Collective


Style React components with real CSS, scoped automatically and delivered only when needed. No class name juggling, no separate files, no build step required.

  • Works everywhere React runs. Server components, client components, streaming SSR, and React Native—same API, automatic runtime detection.
  • Full CSS, no compromises. Media queries, pseudo-selectors, nesting, keyframes, global styles. If CSS supports it, so does styled-components.
  • TypeScript-first. Built-in types ship with the package. Props flow through to your styles with full inference—no @types install, no manual generics.
  • <13kB gzipped. Small enough to disappear in your bundle. No build plugin required.

Install

npm install styled-components
pnpm / yarn
pnpm add styled-components
yarn add styled-components

Quick examples

Dynamic props

Vary styles based on component props. Prefix transient props with $ to keep them off the DOM.

import styled from 'styled-components';

const Button = styled.button<{ $primary?: boolean }>`
  background: ${props => (props.$primary ? 'palevioletred' : 'white')};
  color: ${props => (props.$primary ? 'white' : 'palevioletred')};
  font-size: 1em;
  padding: 0.25em 1em;
  border: 2px solid palevioletred;
  border-radius: 3px;
`;

<Button>Normal</Button>
<Button $primary>Primary</Button>

Extending styles

Build variants on top of existing styled components.

const TomatoButton = styled(Button)`
  background: tomato;
  color: white;
  border-color: tomato;
`;

Polymorphic as prop

Swap the rendered element without changing styles.

// Renders a <a> tag with Button styles
<Button as="a" href="/home">Link Button</Button>

Pseudos and nesting

Use & to reference the component's generated class name—works with pseudo-classes, pseudo-elements, and nested selectors.

const Input = styled.input`
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.5em;

  &:focus {
    border-color: palevioletred;
    outline: none;
  }

  &::placeholder {
    color: #aaa;
  }
`;

Animations

Define @keyframes once, reference them across components. Names are scoped automatically.

import styled, { keyframes } from 'styled-components';

const rotate = keyframes`
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
`;

const Spinner = styled.div`
  animation: ${rotate} 1s linear infinite;
  width: 40px;
  height: 40px;
  border: 3px solid palevioletred;
  border-top-color: transparent;
  border-radius: 50%;
`;

Theming

Share design tokens across your app via React context. Every styled component receives props.theme.

import styled, { ThemeProvider } from 'styled-components';

const theme = {
  fg: 'palevioletred',
  bg: 'white',
};

const Card = styled.div`
  background: ${props => props.theme.bg};
  color: ${props => props.theme.fg};
  padding: 2em;
`;

<ThemeProvider theme={theme}>
  <Card>Themed content</Card>
</ThemeProvider>

RSC-compatible themes

createTheme turns your tokens into CSS custom properties. Class name hashes stay stable across theme variants—no hydration mismatch when switching light/dark.

import styled, { createTheme, ThemeProvider } from 'styled-components';

const { theme, GlobalStyle: ThemeVars } = createTheme({
  colors: {
    fg: 'palevioletred',
    bg: 'white',
  },
  space: {
    md: '1rem',
  },
});

const Card = styled.div`
  color: ${theme.colors.fg};       /* var(--sc-colors-fg, palevioletred) */
  background: ${theme.colors.bg};
  padding: ${theme.space.md};
`;

// Render <ThemeVars /> at the root to emit the CSS variable declarations
// Pass the theme to ThemeProvider for stable hashes
<ThemeProvider theme={theme}>
  <ThemeVars />
  <Card>Token-driven content</Card>
</ThemeProvider>

Shared styles with css

Extract reusable style blocks to share across components or apply conditionally.

import styled, { css } from 'styled-components';

const truncate = css`
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
`;

const Label = styled.span`
  ${truncate}
  max-width: 200px;
`;

Styling third-party components

Wrap any component that accepts a className prop.

import styled from 'styled-components';
import { Link } from 'react-router-dom';

const StyledLink = styled(Link)`
  color: palevioletred;
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
`;

Global styles

Inject app-wide CSS like resets and font faces. Supports theming and dynamic updates.

import { createGlobalStyle } from 'styled-components';

const GlobalStyle = createGlobalStyle`
  body {
    margin: 0;
    font-family: system-ui, sans-serif;
  }
`;

// Render <GlobalStyle /> at the root of your app

Attrs

Set default or static HTML attributes so consumers don't have to.

const PasswordInput = styled.input.attrs({
  type: 'password',
  placeholder: 'Enter password',
})`
  border: 1px solid #ccc;
  padding: 0.5em;
`;

Documentation

Community

Contributing guidelines | Code of Conduct | awesome-styled-components

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! [Become a backer]

Sponsors

Support this project by becoming a sponsor. [Become a sponsor]

Acknowledgements

This project builds on earlier work by Charlie Somerville, Nik Graf, Sunil Pai, Michael Chan, Andrey Popp, Jed Watson, and Andrey Sitnik. Special thanks to @okonet for the logo.

License

Licensed under the MIT License, Copyright © 2016-present styled-components contributors. See LICENSE for details.