Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Installations
npm install styled-components
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Min. Node Version
>= 16
Node Version
20.18.1
NPM Version
10.8.2
Score
86.2
Supply Chain
93.4
Quality
89.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (85.78%)
JavaScript (13.99%)
CSS (0.15%)
HTML (0.09%)
Developer
Download Statistics
Total Downloads
1,136,589,557
Last Day
1,065,095
Last Week
4,752,036
Last Month
21,252,415
Last Year
281,619,755
GitHub Statistics
40,609 Stars
3,639 Commits
2,507 Forks
347 Watching
19 Branches
369 Contributors
Bundle Size
30.19 kB
Minified
11.06 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
6.1.14
Package Id
styled-components@6.1.14
Unpacked Size
1.59 MB
Size
432.95 kB
File Count
148
NPM Version
10.8.2
Node Version
20.18.1
Publised On
04 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
1,136,589,557
Last day
-7.4%
1,065,095
Compared to previous day
Last week
-16.5%
4,752,036
Compared to previous week
Last month
4.8%
21,252,415
Compared to previous month
Last year
-7.6%
281,619,755
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
9
Dev Dependencies
47
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!
1const Button = styled.button` 2 color: grey; 3`;
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.
1const Button = styled.button({ 2 color: 'grey', 3});
Equivalent to:
1const Button = styled.button` 2 color: grey; 3`;
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
1import React from 'react'; 2 3import styled from 'styled-components'; 4 5// Create a <Title> react component that renders an <h1> which is 6// centered, palevioletred and sized at 1.5em 7const Title = styled.h1` 8 font-size: 1.5em; 9 text-align: center; 10 color: palevioletred; 11`; 12 13// Create a <Wrapper> react component that renders a <section> with 14// some padding and a papayawhip background 15const Wrapper = styled.section` 16 padding: 4em; 17 background: papayawhip; 18`; 19 20function MyUI() { 21 return ( 22 // Use them like any other React component – except they're styled! 23 <Wrapper> 24 <Title>Hello World, this is my first styled component!</Title> 25 </Wrapper> 26 ); 27}
This is what you'll see in your 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-components →
1[![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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool is run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Info: all commits (13) are checked with a SAST tool
Reason
4 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 5/26 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/test.yml:11
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/release.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/styled-components/styled-components/test.yml/main?enable=pin
- Info: 0 out of 12 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
23 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-36jr-mh4h-2g58
- Warn: Project is vulnerable to: GHSA-3q56-9cc2-46j4
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-c59h-r6p8-q9wc
- Warn: Project is vulnerable to: GHSA-g77x-44xx-532m
- Warn: Project is vulnerable to: GHSA-7gfc-8cq8-jh5f
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to styled-components
babel-plugin-styled-components
Improve the debugging experience and add server-side rendering support to styled-components
@types/styled-components
TypeScript definitions for styled-components
@xstyled/styled-components
A utility-first CSS-in-JS framework built for React (styled-components bindings).
stylelint-config-styled-components
A shareable stylelint config for stylelint-processor-styled-components