Styled Components is a CSS tool that helps you organize your React project
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress
This library helps you build small, reusable components responsible for the look of your app.
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.
Installing styled-components only takes a single command and you’re ready to roll:
npm install --save styled-components
styled-components utilises tagged template literals to style your components.
Follow this Document to Getting started with Styled Components
See the documentation at styled-components.com/docs for more information about using
Quicklinks to some of the most-visited pages:
styled-components v5 is now officially in beta! Try it out in your project today:
npm install styled-components@beta
- Make sure you’re on a hooks-compatible version of react (>= 16.8 for react, react-dom, and react-is)
- If you use jest-styled-components, upgrade
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:
Official GitHub Link: https://github.com/styled-components/styled-components
I would like to thank you to the creator and Contributors of this Library for a Wonderful job.