question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using theme with Next.js

See original GitHub issue

I’m moving a project over from styled-components and everything has been going super smoothly so far!

I’ve just had some difficulty implementing theming. I used the convention in the useTheme example, but the props don’t even seem to be getting defined (I get a “cannot read property ‘theme’ of undefined” error).

Here’s a CodeSandbox example: https://codesandbox.io/s/runtime-browser-zeuw1

It’s probably a silly error on my part, but I can’t seem to figure it out! Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cristianbotecommented, Feb 2, 2021

Hey @josiahwiebe with the recent PR this got fixed. Checkout your sandbox with the updated version https://codesandbox.io/s/eager-cherry-57c9u.

Will push a new version soon.

0reactions
jlalmescommented, Jul 8, 2021

@cristianbote - Is it possible to add types so that we can use the DefaultTheme inside createGlobalStyles. Currently receiving Parameter 'p' implicitly has an 'any' type.ts(7006).

const GlobalStyles = createGlobalStyles`
  ::selection {
    color: ${(p) => p.theme.color.white()};
    background-color: ${(p) => p.theme.color.primary(0.95)};
  }
`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Theming in Next.js with styled-components and useDarkMode
To use styled-components in a Next.js app, go into the _app · file, import the ThemeProvider component, and wrap the app with the...
Read more >
Implementing Multiple Theme Support in NextJs - Medium
The first step is to create a file theme-options.js in your components folder which would contain variables for all the themes you want...
Read more >
Add Theme UI to your NextJS site - DEV Community ‍ ‍
1. Install theme-ui · 2. Create and export the theme object · 3. Wrap our NextJS app with Theme UI's ThemeProvider.
Read more >
How to Implement Dark/Light Themes in a Next.js App Using ...
In this article, we will Initialize a Next.js application and then implement dark/light theme toggle for it using context hook and TailwindCSS.
Read more >
Theme UI – CSS and Styling – Intro to Next.js
theme ui is a library that allows you to create theme objects and use them in your components. It also handles scoping and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found