Skip to content

Light logo in dark theme #475

Answered by dlarroder
duartecancela asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can use the useTheme() hook to determine the current theme of your application. With that, you can dynamically change the logo you are rendering. For example:

import React from 'react'
import { useTheme } from 'next-themes'
import LightLogo from './LightLogo'
import DarkLogo from './DarkLogo'

export default function Sample() {
  const { theme } = useTheme()

  return (
    <div>
      {theme === 'light' ? <LightLogo /> : <DarkLogo />}
      <span>Nav Menus</span>
    </div>
  )
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@duartecancela
Comment options

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