Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
JavaScript TypeScript HTML CSS
Clone or download
kitten Merge pull request #1883 from bhargav-kitchen/error-handling-non-styl…
…ed-component

Check if React element was mistakenly used within styles
Latest commit f401eda Aug 11, 2018
Permalink
Failed to load latest commit information.
.github add envinfo command to issue template Mar 7, 2018
benchmarks Merge pull request #1852 from styled-components/fix-benchmarks Jul 18, 2018
docs Add ref documentation for React.createRef() Jun 4, 2018
example feat: screenshot test Dec 16, 2017
flow-typed remove lodash flow-typed defs May 25, 2018
integration-test Upgrade Jest to 22 May 15, 2018
native Fix broken isStyledComponent type (#1876) Aug 4, 2018
no-parser drop PropTypes from UMD globals, .es.* -> .esm.* Jun 22, 2018
primitives drop PropTypes from UMD globals, .es.* -> .esm.* Jun 22, 2018
sandbox deleted yarn-error.log file Feb 26, 2018
scripts Update postinstall wording Mar 30, 2018
src Merge pull request #1883 from bhargav-kitchen/error-handling-non-styl… Aug 11, 2018
test-utils Fix flow May 15, 2018
typings #1885: fix missing generic type arguments in .d.ts Aug 5, 2018
.babelrc Flat bundles for each possible entry Dec 19, 2017
.babelrc.js add error system (#1881) Aug 5, 2018
.editorconfig Add editorconfig (#30) Sep 30, 2016
.eslintignore run benchmarks against local styled-components Jul 5, 2018
.eslintrc merge: remote-tracking branch 'origin/master' into fix-1715 Jun 2, 2018
.flowconfig ignore flow on rest of tests Aug 2, 2018
.gitattributes Update test-results.json Nov 29, 2017
.gitignore Add --tracing to benchmarks Jul 5, 2018
.jest.integration.json feat: screenshot test Dec 16, 2017
.jest.native.json Upgrade to enzyme v3 Jan 13, 2018
.jest.primitives.json Upgrade to enzyme v3 Jan 13, 2018
.jest.web.json Use insertRule in the browser Jan 25, 2018
.npmignore Add --tracing to benchmarks Jul 5, 2018
.prettierignore prevent prettier from running on json/yml Apr 12, 2018
.prettierrc remove trailing commas for functions Dec 27, 2017
.travis.yml disable danger for the time being Jun 1, 2018
CHANGELOG.md Merge pull request #1883 from bhargav-kitchen/error-handling-non-styl… Aug 11, 2018
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md Jul 4, 2017
CONTRIBUTING.md Add docs about running the benchmarks Jul 5, 2018
CORE_TEAM.md Add @probablyup to the core team Jan 4, 2018
LICENSE Update license year Jan 5, 2018
README.md add reference to the 4.0 dev branch Aug 9, 2018
appveyor.yml update danger, travis & appveyor configs, bundlesize May 30, 2018
dangerfile.js remove unactionable danger message May 30, 2018
package.json v3.4.2 Aug 7, 2018
rollup.config.js fix primitives build output Aug 11, 2018
tslint.json Fix broken isStyledComponent type (#1876) Aug 4, 2018
yarn.lock ensure stream module is properly removed when not needed Aug 5, 2018

README.md


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

downloads: 600k/month Join the community on Spectrum gzip size module formats: umd, cjs, esm

If you are looking for styled-components v4.0 (under active development), check out the roadmap and dev branch.



Utilising tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allows 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!

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;
`;

// 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:

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’s 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.