Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

styled-components 6.0.8

CSS for the <Component> Age. Style components your way with speed, strong typing, and flexibility.
Package summary
Share
0
issues
0
licenses
Package created
16 Aug 2016
Version published
13 Sep 2023
Maintainers
4
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does styled-components do?

Styled-components is a library for styling React applications. It combines the best of ES6 and CSS to create visual primitives that help developers structure their apps without stress. It utilizes tagged template literals (a recent addition to JavaScript) and the power of CSS, allowing the writing of actual CSS code to style your components. Styled-components removes the mapping between components and styles, promoting the use of components as a low-level styling construct. The library is compatible with both React (for the web) and React Native, making it a perfect choice for universal apps.

How do you use styled-components?

Using styled-components is straightforward. First, you need to install the package using npm: npm install styled-components@^5.0.0 react@^16.8 react-dom@^16.8 react-is@^16.8. Then, you can create styled components using tagged template literals or style objects. Here is a basic example using tagged template literals:

import styled from 'styled-components';

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

And here's how you would do it using style objects:

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

In your React component, you can then use the newly styled Button like any other React component.

Where are the styled-components docs?

For comprehensive information on using styled-components, refer to the official documentation at styled-components.com/docs. Here you can find everything from getting started guides, API references, to more advanced topics like theming and server-side rendering. The documentation also includes an explanation of tagged template literals. For users wanting to upgrade from v4, instructions are provided in the documentation.