From fdd386eabc7f0b757acaa5b4d9355d439c0dcb62 Mon Sep 17 00:00:00 2001
From: Taesu <166604494+bytaesu@users.noreply.github.com>
Date: Tue, 9 Dec 2025 06:59:50 +0900
Subject: [PATCH] docs: improve ThemeToggle component and header layout (#6451)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
---
docs/components/mobile-search-icon.tsx | 2 +-
docs/components/nav-bar.tsx | 2 +-
docs/components/nav-mobile.tsx | 19 ++-
docs/components/theme-toggle.tsx | 207 +++++++++++++++++++++++++
docs/components/theme-toggler.tsx | 189 ----------------------
5 files changed, 218 insertions(+), 201 deletions(-)
create mode 100644 docs/components/theme-toggle.tsx
delete mode 100644 docs/components/theme-toggler.tsx
diff --git a/docs/components/mobile-search-icon.tsx b/docs/components/mobile-search-icon.tsx
index b097bd749c..2b507866e2 100644
--- a/docs/components/mobile-search-icon.tsx
+++ b/docs/components/mobile-search-icon.tsx
@@ -23,7 +23,7 @@ export function MobileSearchIcon({ className }: MobileSearchIconProps) {
aria-label="Search"
onClick={handleSearchClick}
className={cn(
- "flex ring-0 shrink-0 navbar:hidden size-9 hover:bg-transparent",
+ "flex ring-0 shrink-0 navbar:hidden size-8 hover:bg-transparent",
className,
)}
>
diff --git a/docs/components/nav-bar.tsx b/docs/components/nav-bar.tsx
index 907d0ab7f8..ac7fdf9893 100644
--- a/docs/components/nav-bar.tsx
+++ b/docs/components/nav-bar.tsx
@@ -1,6 +1,6 @@
import Link from "next/link";
import { MobileSearchIcon } from "@/components/mobile-search-icon";
-import { ThemeToggle } from "@/components/theme-toggler";
+import { ThemeToggle } from "@/components/theme-toggle";
import DarkPng from "../public/branding/better-auth-logo-dark.png";
import WhitePng from "../public/branding/better-auth-logo-light.png";
import { Logo } from "./logo";
diff --git a/docs/components/nav-mobile.tsx b/docs/components/nav-mobile.tsx
index acbe86bc05..ad1259131b 100644
--- a/docs/components/nav-mobile.tsx
+++ b/docs/components/nav-mobile.tsx
@@ -56,16 +56,15 @@ export const NavbarMobileBtn: React.FC = () => {
const { toggleNavbar } = useNavbarMobile();
return (
-
-
-
+
);
};
diff --git a/docs/components/theme-toggle.tsx b/docs/components/theme-toggle.tsx
new file mode 100644
index 0000000000..4c7e69eab7
--- /dev/null
+++ b/docs/components/theme-toggle.tsx
@@ -0,0 +1,207 @@
+"use client";
+
+import { AnimatePresence, motion } from "framer-motion";
+import { useTheme } from "next-themes";
+import type { ComponentProps } from "react";
+import { useEffect, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+
+const themeMap = {
+ light: "light",
+ dark: "dark",
+} as const;
+
+function renderThemeIcon(theme: string | undefined) {
+ switch (theme) {
+ case themeMap.light:
+ return ;
+ case themeMap.dark:
+ return ;
+ default:
+ return null;
+ }
+}
+
+export function ThemeToggle(props: ComponentProps) {
+ const { setTheme, resolvedTheme } = useTheme();
+ const [mounted, setMounted] = useState(false);
+
+ useEffect(() => {
+ setMounted(true);
+ }, []);
+
+ return (
+
+ );
+}
+
+const LightThemeIcon = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+const DarkThemeIcon = () => {
+ return (
+
+
+
+ );
+};
diff --git a/docs/components/theme-toggler.tsx b/docs/components/theme-toggler.tsx
deleted file mode 100644
index ff100a6ef4..0000000000
--- a/docs/components/theme-toggler.tsx
+++ /dev/null
@@ -1,189 +0,0 @@
-"use client";
-
-import { useTheme } from "next-themes";
-import type { ComponentProps } from "react";
-import { Button } from "@/components/ui/button";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { cn } from "@/lib/utils";
-
-export function ThemeToggle(props: ComponentProps) {
- const { setTheme, theme } = useTheme();
-
- return (
-
-
-
-
-
- setTheme("light")}
- >
- Light
-
- setTheme("dark")}
- >
- Dark
-
- setTheme("system")}
- >
- System
-
-
-
- );
-}