Style React component with styled-components : Part-1

Shahjada Talukdar
2 min readAug 4, 2019

--

Styling your React component is an important part for any real world application.
We can style react components in a couple of ways. such as –
1. inline styling
2. CSS modules
3. emotion
4. styled-components

We will talk about styled-components in this article.

We are gonna create one simple animated loading spinner component.

We can install the package from npmjs using npm or yarn cli.
npm i styled-components --save
Or
yarn add styled-components

We can import that in our Component module like
import styled from "styled-components";

Now I will use the styled API to create the spinner.We are using one DIV as a target for that spinner.

Now we can use this like a react component.

We don’t need any other tool or webpack to build this css. It will work just fine.

I will continue writing more on styled-components.

Till then.
Cheers!
👋

PS: You can also have a look on my blog site https://shahjada.me

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Shahjada Talukdar
Shahjada Talukdar

Written by Shahjada Talukdar

Senior Software Engineer @eBay. Tech enthusiast, loves JS + few other languages. Keen to learn about Software Engineering/Architecture.

No responses yet