Skip to content

Anyone used next-themes to toggle the theme? #441

Answered by saadeghi
lsbyerley asked this question in Q&A
Discussion options

You must be logged in to vote

daisyUI + Next.js + next-themes work as expected. Example repo: https://github.com/saadeghi/daisyui-nextjs-nextthemes

1.mp4

However, instead of constant color names like bg-gray-200 you should use daisyUI color names to get daisyUI themes working.
It's easier to use than Tailwind's dark: prefix because you wont need to set light/dark colors for every element.
For example, instead of

<header className="bg-gray-200 navbar dark:bg-gray-600"></header>

use

<header className="bg-base-200 navbar"></header>

bg-base-200 will be a light color on light theme and will be dark color on dark theme.

Let me know if you have any questions

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@lsbyerley
Comment options

@santgr11
Comment options

@saadeghi
Comment options

Answer selected by saadeghi
Comment options

You must be logged in to vote
3 replies
@Bash4195
Comment options

@Bash4195
Comment options

@raaaahman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants