Getting Started with Styled-Components in Next.js

Getting Started with Styled-Components in Next.js

You can write the actual CSS code to style your components. it also removes the mapping between component and style.

You can write the actual CSS code to style your components. it also removes the mapping between component and style. for me, it’s better than CSS/SASS/SCSS. styled component

I’m using an existing project from the previous article. we will make the pokemon list fancier with styled-components. you can clone here and use branch init.

1. Add a styled component to the project

yarn add styled-components

2. Make Header Component

The header for example and you can try others later with your way. create components folder on the root. inside folder component create folder Header.

Create file StyledHeader.js and create components with styled-components.

import styled from "styled-components";

const StyledHeader = styled.div`
padding: 0;
margin: 0;
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.75);
`;
export default StyledHeader;

You can change for style with your style. with a background or anything else.

Because this file only for custom style, so we need to create index.jsx file for a component view like a general react component.

import StyledHeader from "./StyledHeader";

export default function Header() {
return (
<StyledHeader>
<h1>Pokemon</h1>
</StyledHeader>
);
}

javascript react nextjs

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Increase Performance of React Applications Via Array JavaScript Methods

Increase Performance of React Applications Via Array JavaScript Methods. We will create a simple event management application in the react to add, update, and delete an event.

Top VSCode Extensions for React, React Native, JavaScript and Productivity

Bunch of VSCode Extensions that improve quality of your coding time no matter what stack you are using. In this post, you'll see Top VSCode Extensions for React, React Native, JavaScript and Productivity

Qual a relação entre Java e JavaScript, C e C++, React e React Native

Qual a relação entre Java e JavaScript, C e C++, React e React Native

Routing in React without React-Router

I have been using React JS in my projects for quite some time now and am used to managing routing in my app using the react-router package. I have always been keen on having as little dependencies in my apps as possible, so, I always felt perturbed by the use of this particular package in simpler apps which did not have complex routes.