Next.js Discord

Discord Forum

Theme not properly working

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
For some reason my v0.dev won't get the .tsx file to adjust appropriately to themes.

5 Replies

Sun bearOP
"use client"

import Link from "next/link"
import { usePathname } from "next/navigation"
import { ThemeToggle } from "./theme-toggle"
import { cn } from "@/lib/utils"

const navigation = [
  { name: "Home", href: "/" },
  { name: "Blog", href: "/blog" },
  { name: "Portfolio", href: "/portfolio" },
  { name: "Contact", href: "/contact" },
]

export function Navigation() {
  const pathname = usePathname()

  return (
    <nav className="border-b bg-white dark:bg-black backdrop-blur">
      <div className="container mx-auto px-5">
        <div className="flex h-16 items-center justify-between">
          <Link
            href="/"
            className="text-xl font-bold text-gray-900 dark:text-white hover:text-gray-700 dark:hover:text-gray-300 transition-colors"
          >
            Connor Yao
          </Link>

          <div className="flex items-center space-x-6">
            {navigation.map((item) => (
              <Link
                key={item.name}
                href={item.href}
                className={cn(
                  "text-sm font-medium transition-colors hover:text-blue-600 dark:hover:text-blue-400",
                  pathname === item.href
                    ? "text-blue-600 dark:text-blue-400 font-semibold"
                    : "text-gray-700 dark:text-gray-300",
                )}
              >
                {item.name}
              </Link>
            ))}
            <ThemeToggle />
          </div>
        </div>
      </div>
    </nav>
  )
}
Prompt

- Make the navigation bar background white in light mode and black in dark mode.
- Keep the text color dark gray in light mode and light gray in dark mode.
- The current page link should switch to blue text and slightly bolder weight so it’s clear which tab is active.
- No underline or extra decoration is needed — just the text color change.
- Ensure hover states still turn links blue so the interaction feels consistent.
Californian
Quick checklist for your code:

1. tailwind.config.ts → darkMode: "class"

2. Wrap your app in <ThemeProvider attribute="class">

3. Ensure <html> or <body> can get the dark class applied

4. ThemeToggle updates the theme correctly