How do I use GlobalStyles from styled components in next?

Ricardo de Paula

I'm starting now to learn next. I'm kind of lost on how to apply the createGlobalStyle feature of the sytled components in the framework.

iunfixit

You can use a custom app, by creating a _app.js file in pages directory

import { createGlobalStyle } from 'styled-components'

const GlobalStyle = createGlobalStyle`
  body {
    color: ${props => (props.whiteColor ? 'white' : 'black')};
  }
`

function MyApp({ Component, pageProps }) {
  return <><GlobalStyle whiteColor /><Component {...pageProps} /></>
}

export default MyApp

Check https://nextjs.org/docs/advanced-features/custom-app

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to import Ant Design css styles in GlobalStyles of styled-components.?

How do I correctly use 'styled-components'?

How do I use grid-template-areas in styled-components with react?

How do I get a variable from a graphQl query into a pseudo element in either inline styles or styled components

How can I use styled-components CDN build on browser?

How can I use custom icon in react-styled components?

How can I use animation in styled-components css``?

How do I set a option to selected using styled-components?

How do I pass a variable/literal for a value in styled components?

How do I stick to the button right in header using styled components?

How can i do multiple onClick animations in Styled components?

How do I turn this CSS code into Styled-Components?

How can I style a Select from Material UI with styled components?

How to style material ui next components with styled components and SASS

How to use Material colours in react styled components?

How to use styled-components in react component

How to use this.props in React Styled Components

how to use variables conditionally in styled components

How to use Styled Components for a component passed as props

How to use styled Components with Material UI Icons

How to use styled components with Material UI input?

styled-components — how to use :not() selector on a prop?

How to do overlapping styles with Styled Components React?

Next.js using getServerSideProps how do i pass props from page to components?

When do I use attrs vs passing props directly with styled-components?

How to style Next.js active link with Styled Components

How do I use stateful components with redux?

How do i use Blazor components in the code?

How can I use styled components for an element that doesn't appear on initial render?