styled-components
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Last updated 8 years ago by mxstbr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install styled-components 
SYNC missed versions from official npm registry.
styled-components

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

downloads: 600k/month Discord gzip size module formats: umd, cjs, esm Code Coverage

Upgrading from v5? See the migration guide.

Utilizing tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allow you to write actual CSS code to style your components. It also removes the mapping between components and styles – using components as a low-level styling construct could not be easier!

const Button = styled.button`
  color: grey;
`;

Alternatively, you may use style objects. This allows for easy porting of CSS from inline styles, while still supporting the more advanced styled-components capabilities like component selectors and media queries.

const Button = styled.button({
  color: 'grey',
});

Equivalent to:

const Button = styled.button`
  color: grey;
`;

styled-components is compatible with both React (for web) and React Native – meaning it's the perfect choice even for truly universal apps! See the documentation about React Native for more information.

Supported by Front End Center. Thank you for making this possible!


Docs

See the documentation at styled-components.com/docs for more information about using styled-components!

Quicklinks to some of the most-visited pages:


Example

import React from 'react';

import styled from 'styled-components';

// Create a <Title> react component that renders an <h1> which is
// centered, palevioletred and sized at 1.5em
const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

// Create a <Wrapper> react component that renders a <section> with
// some padding and a papayawhip background
const Wrapper = styled.section`
  padding: 4em;
  background: papayawhip;
`;

function MyUI() {
  return (
    // Use them like any other React component – except they're styled!
    <Wrapper>
      <Title>Hello World, this is my first styled component!</Title>
    </Wrapper>
  );
}

This is what you'll see in your browser:

Screenshot of the above code ran in a browser

Looking for v5?

The main branch is for the most-current version of styled-components, currently v6. For changes targeting v5, please point your PRs at the legacy-v5 branch.


Built with styled-components

A lot of hard work goes into community libraries, projects, and guides. A lot of them make it easier to get started or help you with your next project! There are also a whole lot of interesting apps and sites that people have built using styled-components.

Make sure to head over to awesome-styled-components to see them all! And please contribute and add your own work to the list so others can find it.


Contributing

If you want to contribute to styled-components please see our contributing and community guidelines, they'll help you get set up locally and explain the whole process.

Please also note that all repositories under the styled-components organization follow our Code of Conduct, make sure to review and follow it.


Badge

Let everyone know you're using styled-componentsstyle: styled-components

[![style: styled-components](https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e)](https://github.com/styled-components/styled-components)

Contributors

This project exists thanks to all the people who contribute. [Contribute].


Backers

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


Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]


License

Licensed under the MIT License, Copyright © 2016-present Glen Maddern and Maximilian Stoiber.

See LICENSE for more information.


Acknowledgements

This project builds on a long line of earlier work by clever folks all around the world. We'd like to thank Charlie Somerville, Nik Graf, Sunil Pai, Michael Chan, Andrey Popp, Jed Watson & Andrey Sitnik who contributed ideas, code or inspiration.

Special thanks to @okonet for the fantastic logo.

Current Tags

  • 6.0.0-alpha.7                                ...           alpha (2 years ago)
  • 6.0.0-rc.0                                ...           beta (2 years ago)
  • 6.1.13                                ...           latest (3 months ago)
  • 6.0.0-rc.2-4007                                ...           pr-4007 (a year ago)
  • 5.3.1-pr3563                                ...           pr3563 (3 years ago)
  • 5.3.1-pr3564                                ...           pr3564 (3 years ago)
  • 6.1.9-react-18-streaming-prototype                                ...           react-18-streaming-prototype (6 months ago)
  • 6.1.10-test.1                                ...           test (6 months ago)

358 Versions

  • 6.1.13                                ...           3 months ago
  • 6.1.12                                ...           4 months ago
  • 6.1.11                                ...           6 months ago
  • 6.1.10-test.1                                ...           6 months ago
  • 6.1.10-test.0                                ...           6 months ago
  • 6.1.10                                ...           6 months ago
  • 6.1.9                                ...           6 months ago
  • 6.1.9-react-18-streaming-prototype                                ...           6 months ago
  • 6.1.8                                ...           10 months ago
  • 6.1.7                                ...           10 months ago
  • 6.1.6                                ...           a year ago
  • 6.1.5                                ...           a year ago
  • 6.1.5-rc.0                                ...           a year ago
  • 6.1.4                                ...           a year ago
  • 6.1.3                                ...           a year ago
  • 6.1.2                                ...           a year ago
  • 6.1.1                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.9                                ...           a year ago
  • 6.0.8                                ...           a year ago
  • 6.0.7                                ...           a year ago
  • 6.0.6                                ...           a year ago
  • 6.0.6-test.0                                ...           a year ago
  • 6.0.5                                ...           a year ago
  • 6.0.4                                ...           a year ago
  • 6.0.3                                ...           a year ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 6.0.0-rc.6                                ...           a year ago
  • 6.0.0-rc.5                                ...           a year ago
  • 6.0.0-rc.4                                ...           a year ago
  • 6.0.0-rc.3                                ...           a year ago
  • 6.0.0-rc.2-4007                                ...           a year ago
  • 5.3.11                                ...           a year ago
  • 6.0.0-rc.2                                ...           a year ago
  • 6.0.0-rc.1                                ...           2 years ago
  • 6.0.0-rc.0                                ...           2 years ago
  • 5.3.10                                ...           2 years ago
  • 6.0.0-beta.15                                ...           2 years ago
  • 6.0.0-beta.14                                ...           2 years ago
  • 5.3.9                                ...           2 years ago
  • 6.0.0-beta.13                                ...           2 years ago
  • 5.3.8                                ...           2 years ago
  • 6.0.0-beta.12                                ...           2 years ago
  • 5.3.7                                ...           2 years ago
  • 6.0.0-beta.11                                ...           2 years ago
  • 6.0.0-beta.10                                ...           2 years ago
  • 6.0.0-beta.9                                ...           2 years ago
  • 6.0.0-beta.8                                ...           2 years ago
  • 6.0.0-beta.7                                ...           2 years ago
  • 6.0.0-beta.6                                ...           2 years ago
  • 6.0.0-beta.5                                ...           2 years ago
  • 6.0.0-beta.4                                ...           2 years ago
  • 6.0.0-beta.3                                ...           2 years ago
  • 5.3.6                                ...           2 years ago
  • 6.0.0-beta.2                                ...           2 years ago
  • 6.0.0-beta.1                                ...           2 years ago
  • 6.0.0-beta.0                                ...           2 years ago
  • 6.0.0-alpha.7                                ...           2 years ago
  • 6.0.0-alpha.6                                ...           2 years ago
  • 6.0.0-alpha.5                                ...           3 years ago
  • 5.3.5                                ...           3 years ago
  • 6.0.0-alpha.4                                ...           3 years ago
  • 6.0.0-alpha.3                                ...           3 years ago
  • 6.0.0-alpha.2                                ...           3 years ago
  • 5.3.4                                ...           3 years ago
  • 6.0.0-alpha.1                                ...           3 years ago
  • 6.0.0-alpha.0                                ...           3 years ago
  • 5.3.3                                ...           3 years ago
  • 5.3.2                                ...           3 years ago
  • 5.3.1                                ...           3 years ago
  • 5.3.1-pr3564                                ...           3 years ago
  • 5.3.1-pr3563                                ...           3 years ago
  • 5.3.0                                ...           4 years ago
  • 5.2.3                                ...           4 years ago
  • 5.2.2                                ...           4 years ago
  • 5.2.1                                ...           4 years ago
  • 5.2.0                                ...           4 years ago
  • 5.2.0-test.12                                ...           4 years ago
  • 5.2.0-test.11                                ...           4 years ago
  • 5.2.0-test.10                                ...           4 years ago
  • 5.2.0-test.9                                ...           4 years ago
  • 5.2.0-test.8                                ...           4 years ago
  • 5.2.0-test.7                                ...           4 years ago
  • 5.2.0-test.6                                ...           4 years ago
  • 5.2.0-test.5                                ...           4 years ago
  • 5.2.0-test.4                                ...           4 years ago
  • 5.2.0-test.3                                ...           4 years ago
  • 5.2.0-test.2                                ...           4 years ago
  • 5.2.0-test.1                                ...           4 years ago
  • 5.2.0-test.0                                ...           4 years ago
  • 5.1.1                                ...           4 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.1-revisedssr                                ...           5 years ago
  • 5.0.1                                ...           5 years ago
  • 5.0.0-testgrouplimit.0                                ...           5 years ago
  • 5.0.0-testdeopt2                                ...           5 years ago
  • 5.0.0-testdeopt                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 5.0.0-cgsmem                                ...           5 years ago
  • 5.0.0-rc.3                                ...           5 years ago
  • 5.0.0-fixhoist                                ...           5 years ago
  • 5.0.0-rc.2                                ...           5 years ago
  • 5.0.0-regexrehydrate                                ...           5 years ago
  • 5.0.0-rc.1                                ...           5 years ago
  • 4.4.1                                ...           5 years ago
  • 5.0.0-rc.0                                ...           5 years ago
  • 5.0.0-beta.11-cgsmulti                                ...           5 years ago
  • 5.0.0-beta.11                                ...           5 years ago
  • 5.0.0-beta.10-rulefix                                ...           5 years ago
  • 5.0.0-beta.10                                ...           5 years ago
  • 4.4.0-reactnativewebfix                                ...           5 years ago
  • 4.4.0                                ...           5 years ago
  • 5.0.0-beta.9                                ...           5 years ago
  • 5.0.0-beta.8-groupsizefix                                ...           5 years ago
  • 5.0.0-beta.8                                ...           5 years ago
  • 5.0.0-beta.6-ej4                                ...           5 years ago
  • 5.0.0-beta.6-ej3                                ...           5 years ago
  • 5.0.0-beta.6-ej2                                ...           5 years ago
  • 5.0.0-beta.6-ej1                                ...           5 years ago
  • 5.0.0-beta.6-ej                                ...           5 years ago
  • 5.0.0-beta.6                                ...           5 years ago
  • 5.0.0-beta.5-removefoldedcomponentids                                ...           5 years ago
  • 5.0.0-beta.5-ej2                                ...           5 years ago
  • 5.0.0-beta.5                                ...           5 years ago
  • 5.0.0-beta.4                                ...           5 years ago
  • 4.3.2                                ...           5 years ago
  • 5.0.0-beta.3                                ...           5 years ago
  • 5.0.0-beta.2                                ...           5 years ago
  • 5.0.0-beta.1                                ...           5 years ago
  • 5.0.0-beta.0                                ...           5 years ago
  • 5.0.0-alpha.2                                ...           5 years ago
  • 5.0.0-alpha.1                                ...           5 years ago
  • 5.0.0-alpha.0                                ...           5 years ago
  • 4.3.1                                ...           5 years ago
  • 4.3.1-0                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 5.0.0-5.canary-sheet                                ...           5 years ago
  • 5.0.0-4.canary-sheet                                ...           6 years ago
  • 5.0.0-3.canary-sheet                                ...           6 years ago
  • 5.0.0-1.canary-sheet                                ...           6 years ago
  • 5.0.0-0.canary-sheet                                ...           6 years ago
  • 4.2.0                                ...           6 years ago
  • 4.1.4-alpha.6                                ...           6 years ago
  • 4.1.4-alpha.5                                ...           6 years ago
  • 4.1.4-alpha.4                                ...           6 years ago
  • 4.1.4-alpha.3                                ...           6 years ago
  • 4.1.4-alpha.2                                ...           6 years ago
  • 4.1.3                                ...           6 years ago
  • 3.5.0-0                                ...           6 years ago
  • 4.1.2                                ...           6 years ago
  • 4.1.1                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.1.0-rehydrate                                ...           6 years ago
  • 4.0.3                                ...           6 years ago
  • 4.0.3-0                                ...           6 years ago
  • 4.0.2                                ...           6 years ago
  • 4.0.1                                ...           6 years ago
  • 4.0.1-0                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 4.0.0-beta.11.3                                ...           6 years ago
  • 3.4.10                                ...           6 years ago
  • 4.0.0-beta.11.2                                ...           6 years ago
  • 4.0.0-beta.11.1-hmr2                                ...           6 years ago
  • 4.0.0-beta.11.1-hmr                                ...           6 years ago
  • 4.0.0-beta.11.1                                ...           6 years ago
  • 4.0.0-beta.11                                ...           6 years ago
  • 4.0.0-beta.9-macro2                                ...           6 years ago
  • 4.0.0-beta.9-macro                                ...           6 years ago
  • 4.0.0-beta.10-5                                ...           6 years ago
  • 4.0.0-beta.10-4                                ...           6 years ago
  • 4.0.0-beta.10-3                                ...           6 years ago
  • 4.0.0-beta.10-2                                ...           6 years ago
  • 4.0.0-beta.10-1                                ...           6 years ago
  • 4.0.0-beta.10                                ...           6 years ago
  • 4.0.0-beta.9                                ...           6 years ago
  • 4.0.0-beta.8-unpure                                ...           6 years ago
  • 4.0.0-beta.8                                ...           6 years ago
  • 4.0.0-beta.7-hoist                                ...           6 years ago
  • 3.4.9                                ...           6 years ago
  • 4.0.0-beta.7                                ...           6 years ago
  • 3.4.8                                ...           6 years ago
  • 3.4.7                                ...           6 years ago
  • 4.0.0-beta.6                                ...           6 years ago
  • 4.0.0-beta.5                                ...           6 years ago
  • 4.0.0-beta.4-hmr                                ...           6 years ago
  • 4.0.0-beta.4                                ...           6 years ago
  • 4.0.0-beta.3-purecomponent                                ...           6 years ago
  • 4.0.0-beta.3-side-effect-test                                ...           6 years ago
  • 4.0.0-beta.3                                ...           6 years ago
  • 3.4.6                                ...           6 years ago
  • 4.0.0-beta.2-0                                ...           6 years ago
  • 4.0.0-beta.2                                ...           6 years ago
  • 4.0.0-beta.1-2                                ...           6 years ago
  • 4.0.0-beta.1-1                                ...           6 years ago
  • 4.0.0-beta.1                                ...           6 years ago
  • 4.0.0-beta.0-2                                ...           6 years ago
  • 4.0.0-beta.0-1                                ...           6 years ago
  • 4.0.0-beta.0                                ...           6 years ago
  • 3.4.5                                ...           6 years ago
  • 3.4.4                                ...           6 years ago
  • 3.4.3                                ...           6 years ago
  • 3.4.2                                ...           6 years ago
  • 3.4.1                                ...           6 years ago
  • 3.4.0                                ...           6 years ago
  • 3.4.0-4                                ...           6 years ago
  • 3.4.0-0                                ...           6 years ago
  • 3.3.3                                ...           6 years ago
  • 3.3.3-3                                ...           6 years ago
  • 3.3.3-2                                ...           6 years ago
  • 3.3.3-1                                ...           6 years ago
  • 3.3.2                                ...           6 years ago
  • 3.3.1-beta.0                                ...           6 years ago
  • 2.4.1                                ...           6 years ago
  • 3.3.1                                ...           6 years ago
  • 3.3.0                                ...           6 years ago
  • 3.2.6                                ...           7 years ago
  • 3.2.5                                ...           7 years ago
  • 3.2.4                                ...           7 years ago
  • 3.2.3                                ...           7 years ago
  • 3.2.3-ssrmem1                                ...           7 years ago
  • 3.2.2                                ...           7 years ago
  • 3.2.2-1                                ...           7 years ago
  • 3.2.2-0                                ...           7 years ago
  • 3.2.1                                ...           7 years ago
  • 3.2.1-2                                ...           7 years ago
  • 3.2.1-1                                ...           7 years ago
  • 3.2.1-0                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.2.0-1                                ...           7 years ago
  • 3.2.0-0                                ...           7 years ago
  • 3.2.0-stylerefactor2                                ...           7 years ago
  • 3.2.0-stylerefactor1                                ...           7 years ago
  • 3.1.6                                ...           7 years ago
  • 3.1.6-2                                ...           7 years ago
  • 3.1.6-1                                ...           7 years ago
  • 3.1.6-0                                ...           7 years ago
  • 3.1.5                                ...           7 years ago
  • 3.1.4                                ...           7 years ago
  • 3.1.3                                ...           7 years ago
  • 3.1.2                                ...           7 years ago
  • 3.1.1                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.1.0-speedy6                                ...           7 years ago
  • 3.1.0-speedy5                                ...           7 years ago
  • 3.1.0-speedy4                                ...           7 years ago
  • 3.1.0-speedy3                                ...           7 years ago
  • 3.1.0-speedy2                                ...           7 years ago
  • 3.1.0-speedy                                ...           7 years ago
  • 3.1.0-3                                ...           7 years ago
  • 3.1.0-1                                ...           7 years ago
  • 3.1.0-0                                ...           7 years ago
  • 3.0.2                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 2.5.0-1                                ...           7 years ago
  • 2.4.0                                ...           7 years ago
  • 2.4.0-0                                ...           7 years ago
  • 2.3.3                                ...           7 years ago
  • 2.3.3-0                                ...           7 years ago
  • 2.3.2                                ...           7 years ago
  • 2.3.1                                ...           7 years ago
  • 2.3.0                                ...           7 years ago
  • 2.2.4                                ...           7 years ago
  • 2.2.3                                ...           7 years ago
  • 2.2.2                                ...           7 years ago
  • 2.2.1                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.3-0                                ...           7 years ago
  • 2.1.2                                ...           7 years ago
  • 2.1.1-1                                ...           7 years ago
  • 2.1.1                                ...           7 years ago
  • 2.1.1-0                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 2.0.0-19                                ...           7 years ago
  • 2.0.0-18                                ...           7 years ago
  • 1.4.6                                ...           8 years ago
  • 2.0.0-17                                ...           8 years ago
  • 2.0.0-16                                ...           8 years ago
  • 1.4.5                                ...           8 years ago
  • 2.0.0-15                                ...           8 years ago
  • 2.0.0-14                                ...           8 years ago
  • 2.0.0-13                                ...           8 years ago
  • 2.0.0-12                                ...           8 years ago
  • 2.0.0-11                                ...           8 years ago
  • 2.0.0-10                                ...           8 years ago
  • 2.0.0-9                                ...           8 years ago
  • 2.0.0-8                                ...           8 years ago
  • 2.0.0-7                                ...           8 years ago
  • 2.0.0-6                                ...           8 years ago
  • 1.4.4                                ...           8 years ago
  • 2.0.0-5                                ...           8 years ago
  • 2.0.0-4                                ...           8 years ago
  • 2.0.0-3                                ...           8 years ago
  • 2.0.0-2                                ...           8 years ago
  • 1.4.3                                ...           8 years ago
  • 2.0.0-1                                ...           8 years ago
  • 1.4.2                                ...           8 years ago
  • 1.4.1                                ...           8 years ago
  • 1.4.0                                ...           8 years ago
  • 2.0.0-0                                ...           8 years ago
  • 1.3.1                                ...           8 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.3                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.2-0                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.12-0                                ...           8 years ago
  • 1.0.11                                ...           8 years ago
  • 1.0.10                                ...           8 years ago
  • 1.0.9                                ...           8 years ago
  • 1.0.8                                ...           8 years ago
  • 1.0.7                                ...           8 years ago
  • 1.0.6                                ...           8 years ago
  • 1.0.5                                ...           8 years ago
  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.4.2                                ...           8 years ago
  • 0.4.1                                ...           8 years ago
  • 0.4.0                                ...           8 years ago
  • 0.3.4                                ...           8 years ago
  • 0.3.3                                ...           8 years ago
  • 0.3.2                                ...           8 years ago
  • 0.3.1                                ...           8 years ago
  • 0.3.0                                ...           8 years ago
  • 0.2.5                                ...           8 years ago
  • 0.2.4                                ...           8 years ago
  • 0.2.3                                ...           8 years ago
  • 0.2.2                                ...           8 years ago
  • 0.2.1                                ...           8 years ago
  • 0.2.0                                ...           8 years ago
  • 0.1.9                                ...           8 years ago
  • 0.1.8                                ...           8 years ago
  • 0.1.7                                ...           8 years ago
  • 0.1.6                                ...           8 years ago
  • 0.1.5                                ...           8 years ago
  • 0.1.4                                ...           8 years ago
  • 0.1.3                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.5-2                                ...           8 years ago
  • 0.0.5-1                                ...           8 years ago
  • 0.0.5-0                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (2)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)

© 2010 - cnpmjs.org x YWFE | Home | YWFE