Skip to content

Email for professionals and teams

feat: dark mode with a light/dark/system theme setting

Vagner Rodriguesa133ecf3e411
diff --git a/src/app/(settings)/settings/inbox/page.tsx b/src/app/(settings)/settings/inbox/page.tsx
index ceb4422..fc7692f 100644
--- a/src/app/(settings)/settings/inbox/page.tsx
+++ b/src/app/(settings)/settings/inbox/page.tsx
@@ -1,3 +1,4 @@
+import { AppearanceSettings } from "@/components/settings/appearance-settings";
import { InboxThreadingSettings } from "@/components/settings/inbox-threading-settings";
import { InboxReadingLayoutSettings } from "@/components/settings/inbox-reading-layout-settings";
import { InboxShortcutsSettings } from "@/components/settings/inbox-shortcuts-settings";
@@ -14,6 +15,13 @@ export default function SettingsInboxPage() {
<p className="mt-1 text-sm text-neutral-500">Choose how you read and interact with email.</p>
</div>
<div className="divide-y divide-neutral-100 rounded-3xl bg-white p-6">
+ <div className="py-6 first:pt-0 last:pb-0">
+ <div className="mb-4">
+ <h3 className="text-base font-semibold text-neutral-900">Appearance</h3>
+ <p className="mt-1 text-sm text-neutral-500">Choose a light or dark interface.</p>
+ </div>
+ <AppearanceSettings />
+ </div>
<div className="py-6 first:pt-0 last:pb-0">
<div className="mb-4">
<h3 className="text-base font-semibold text-neutral-900">Reading layout</h3>
diff --git a/src/app/globals.css b/src/app/globals.css
index e8df085..93720cd 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -173,4 +173,287 @@ pre {
button {
cursor: pointer;
-}
\ No newline at end of file
+}
+
+/* ── Dark theme ──────────────────────────────────────────────────────────────
+ Screens use the Tailwind palette directly (bg-white, text-neutral-900, bg-blue-50…). Rather than
+ editing every component, the dark theme remaps the palette variables under .dark: neutrals follow
+ Gmail's dark palette (#202124, #303134, #3c4043, #9aa0a6, #e8eaed…) and accents are inverted
+ (50↔950, 100↔900…). The exceptions come right after. The .dark class is set on <html>
+ (theme-utils.ts). */
+.dark {
+ color-scheme: dark;
+ --background: #202124;
+ --foreground: #e8eaed;
+ --card: #292a2d;
+ --muted: #303134;
+ --border: #3c4043;
+ --primary: #8ab4f8;
+ --primary-foreground: #202124;
+ --color-white: #292a2d;
+ --color-black: #000;
+ --color-neutral-50: #303134;
+ --color-neutral-100: #35363a;
+ --color-neutral-200: #3c4043;
+ --color-neutral-300: #5f6368;
+ --color-neutral-400: #80868b;
+ --color-neutral-500: #9aa0a6;
+ --color-neutral-600: #bdc1c6;
+ --color-neutral-700: #dadce0;
+ --color-neutral-800: #e8eaed;
+ --color-neutral-900: #f1f3f4;
+ --color-neutral-950: #ffffff;
+ --color-gray-50: #303134;
+ --color-gray-100: #35363a;
+ --color-gray-200: #3c4043;
+ --color-gray-300: #5f6368;
+ --color-gray-400: #80868b;
+ --color-gray-500: #9aa0a6;
+ --color-gray-600: #bdc1c6;
+ --color-gray-700: #dadce0;
+ --color-gray-800: #e8eaed;
+ --color-gray-900: #f1f3f4;
+ --color-gray-950: #ffffff;
+ --color-stone-50: #303134;
+ --color-stone-100: #35363a;
+ --color-stone-200: #3c4043;
+ --color-stone-300: #5f6368;
+ --color-stone-400: #80868b;
+ --color-stone-500: #9aa0a6;
+ --color-stone-600: #bdc1c6;
+ --color-stone-700: #dadce0;
+ --color-stone-800: #e8eaed;
+ --color-stone-900: #f1f3f4;
+ --color-stone-950: #ffffff;
+ --color-zinc-50: #303134;
+ --color-zinc-100: #35363a;
+ --color-zinc-200: #3c4043;
+ --color-zinc-300: #5f6368;
+ --color-zinc-400: #80868b;
+ --color-zinc-500: #9aa0a6;
+ --color-zinc-600: #bdc1c6;
+ --color-zinc-700: #dadce0;
+ --color-zinc-800: #e8eaed;
+ --color-zinc-900: #f1f3f4;
+ --color-zinc-950: #ffffff;
+ --color-slate-50: #303134;
+ --color-slate-100: #35363a;
+ --color-slate-200: #3c4043;
+ --color-slate-300: #5f6368;
+ --color-slate-400: #80868b;
+ --color-slate-500: #9aa0a6;
+ --color-slate-600: #bdc1c6;
+ --color-slate-700: #dadce0;
+ --color-slate-800: #e8eaed;
+ --color-slate-900: #f1f3f4;
+ --color-slate-950: #ffffff;
+ --color-blue-50: #2c3d57;
+ --color-blue-100: #33486a;
+ --color-blue-200: oklch(42.4% 0.199 265.638);
+ --color-blue-300: oklch(48.8% 0.243 264.376);
+ --color-blue-400: oklch(54.6% 0.245 262.881);
+ --color-blue-500: oklch(62.3% 0.214 259.815);
+ --color-blue-600: oklch(70.7% 0.165 254.624);
+ --color-blue-700: oklch(80.9% 0.105 251.813);
+ --color-blue-800: oklch(88.2% 0.059 254.128);
+ --color-blue-900: oklch(93.2% 0.032 255.585);
+ --color-blue-950: oklch(97% 0.014 254.604);
+ --color-red-50: oklch(25.8% 0.092 26.042);
+ --color-red-100: oklch(39.6% 0.141 25.723);
+ --color-red-200: oklch(44.4% 0.177 26.899);
+ --color-red-300: oklch(50.5% 0.213 27.518);
+ --color-red-400: oklch(57.7% 0.245 27.325);
+ --color-red-500: oklch(63.7% 0.237 25.331);
+ --color-red-600: oklch(70.4% 0.191 22.216);
+ --color-red-700: oklch(80.8% 0.114 19.571);
+ --color-red-800: oklch(88.5% 0.062 18.334);
+ --color-red-900: oklch(93.6% 0.032 17.717);
+ --color-red-950: oklch(97.1% 0.013 17.38);
+ --color-green-50: oklch(26.6% 0.065 152.934);
+ --color-green-100: oklch(39.3% 0.095 152.535);
+ --color-green-200: oklch(44.8% 0.119 151.328);
+ --color-green-300: oklch(52.7% 0.154 150.069);
+ --color-green-400: oklch(62.7% 0.194 149.214);
+ --color-green-500: oklch(72.3% 0.219 149.579);
+ --color-green-600: oklch(79.2% 0.209 151.711);
+ --color-green-700: oklch(87.1% 0.15 154.449);
+ --color-green-800: oklch(92.5% 0.084 155.995);
+ --color-green-900: oklch(96.2% 0.044 156.743);
+ --color-green-950: oklch(98.2% 0.018 155.826);
+ --color-amber-50: oklch(27.9% 0.077 45.635);
+ --color-amber-100: oklch(41.4% 0.112 45.904);
+ --color-amber-200: oklch(47.3% 0.137 46.201);
+ --color-amber-300: oklch(55.5% 0.163 48.998);
+ --color-amber-400: oklch(66.6% 0.179 58.318);
+ --color-amber-500: oklch(76.9% 0.188 70.08);
+ --color-amber-600: oklch(82.8% 0.189 84.429);
+ --color-amber-700: oklch(87.9% 0.169 91.605);
+ --color-amber-800: oklch(92.4% 0.12 95.746);
+ --color-amber-900: oklch(96.2% 0.059 95.617);
+ --color-amber-950: oklch(98.7% 0.022 95.277);
+ --color-sky-50: oklch(29.3% 0.066 243.157);
+ --color-sky-100: oklch(39.1% 0.09 240.876);
+ --color-sky-200: oklch(44.3% 0.11 240.79);
+ --color-sky-300: oklch(50% 0.134 242.749);
+ --color-sky-400: oklch(58.8% 0.158 241.966);
+ --color-sky-500: oklch(68.5% 0.169 237.323);
+ --color-sky-600: oklch(74.6% 0.16 232.661);
+ --color-sky-700: oklch(82.8% 0.111 230.318);
+ --color-sky-800: oklch(90.1% 0.058 230.902);
+ --color-sky-900: oklch(95.1% 0.026 236.824);
+ --color-sky-950: oklch(97.7% 0.013 236.62);
+ --color-violet-50: oklch(28.3% 0.141 291.089);
+ --color-violet-100: oklch(38% 0.189 293.745);
+ --color-violet-200: oklch(43.2% 0.232 292.759);
+ --color-violet-300: oklch(49.1% 0.27 292.581);
+ --color-violet-400: oklch(54.1% 0.281 293.009);
+ --color-violet-500: oklch(60.6% 0.25 292.717);
+ --color-violet-600: oklch(70.2% 0.183 293.541);
+ --color-violet-700: oklch(81.1% 0.111 293.571);
+ --color-violet-800: oklch(89.4% 0.057 293.283);
+ --color-violet-900: oklch(94.3% 0.029 294.588);
+ --color-violet-950: oklch(96.9% 0.016 293.756);
+ --color-teal-50: oklch(27.7% 0.046 192.524);
+ --color-teal-100: oklch(38.6% 0.063 188.416);
+ --color-teal-200: oklch(43.7% 0.078 188.216);
+ --color-teal-300: oklch(51.1% 0.096 186.391);
+ --color-teal-400: oklch(60% 0.118 184.704);
+ --color-teal-500: oklch(70.4% 0.14 182.503);
+ --color-teal-600: oklch(77.7% 0.152 181.912);
+ --color-teal-700: oklch(85.5% 0.138 181.071);
+ --color-teal-800: oklch(91% 0.096 180.426);
+ --color-teal-900: oklch(95.3% 0.051 180.801);
+ --color-teal-950: oklch(98.4% 0.014 180.72);
+ --color-pink-50: oklch(28.4% 0.109 3.907);
+ --color-pink-100: oklch(40.8% 0.153 2.432);
+ --color-pink-200: oklch(45.9% 0.187 3.815);
+ --color-pink-300: oklch(52.5% 0.223 3.958);
+ --color-pink-400: oklch(59.2% 0.249 0.584);
+ --color-pink-500: oklch(65.6% 0.241 354.308);
+ --color-pink-600: oklch(71.8% 0.202 349.761);
+ --color-pink-700: oklch(82.3% 0.12 346.018);
+ --color-pink-800: oklch(89.9% 0.061 343.231);
+ --color-pink-900: oklch(94.8% 0.028 342.258);
+ --color-pink-950: oklch(97.1% 0.014 343.198);
+ --color-orange-50: oklch(26.6% 0.079 36.259);
+ --color-orange-100: oklch(40.8% 0.123 38.172);
+ --color-orange-200: oklch(47% 0.157 37.304);
+ --color-orange-300: oklch(55.3% 0.195 38.402);
+ --color-orange-400: oklch(64.6% 0.222 41.116);
+ --color-orange-500: oklch(70.5% 0.213 47.604);
+ --color-orange-600: oklch(75% 0.183 55.934);
+ --color-orange-700: oklch(83.7% 0.128 66.29);
+ --color-orange-800: oklch(90.1% 0.076 70.697);
+ --color-orange-900: oklch(95.4% 0.038 75.164);
+ --color-orange-950: oklch(98% 0.016 73.684);
+ --color-rose-50: oklch(27.1% 0.105 12.094);
+ --color-rose-100: oklch(41% 0.159 10.272);
+ --color-rose-200: oklch(45.5% 0.188 13.697);
+ --color-rose-300: oklch(51.4% 0.222 16.935);
+ --color-rose-400: oklch(58.6% 0.253 17.585);
+ --color-rose-500: oklch(64.5% 0.246 16.439);
+ --color-rose-600: oklch(71.2% 0.194 13.428);
+ --color-rose-700: oklch(81% 0.117 11.638);
+ --color-rose-800: oklch(89.2% 0.058 10.001);
+ --color-rose-900: oklch(94.1% 0.03 12.58);
+ --color-rose-950: oklch(96.9% 0.015 12.422);
+ --color-emerald-50: oklch(26.2% 0.051 172.552);
+ --color-emerald-100: oklch(37.8% 0.077 168.94);
+ --color-emerald-200: oklch(43.2% 0.095 166.913);
+ --color-emerald-300: oklch(50.8% 0.118 165.612);
+ --color-emerald-400: oklch(59.6% 0.145 163.225);
+ --color-emerald-500: oklch(69.6% 0.17 162.48);
+ --color-emerald-600: oklch(76.5% 0.177 163.223);
+ --color-emerald-700: oklch(84.5% 0.143 164.978);
+ --color-emerald-800: oklch(90.5% 0.093 164.15);
+ --color-emerald-900: oklch(95% 0.052 163.051);
+ --color-emerald-950: oklch(97.9% 0.021 166.113);
+ --color-cyan-50: oklch(30.2% 0.056 229.695);
+ --color-cyan-100: oklch(39.8% 0.07 227.392);
+ --color-cyan-200: oklch(45% 0.085 224.283);
+ --color-cyan-300: oklch(52% 0.105 223.128);
+ --color-cyan-400: oklch(60.9% 0.126 221.723);
+ --color-cyan-500: oklch(71.5% 0.143 215.221);
+ --color-cyan-600: oklch(78.9% 0.154 211.53);
+ --color-cyan-700: oklch(86.5% 0.127 207.078);
+ --color-cyan-800: oklch(91.7% 0.08 205.041);
+ --color-cyan-900: oklch(95.6% 0.045 203.388);
+ --color-cyan-950: oklch(98.4% 0.019 200.873);
+ --color-yellow-50: oklch(28.6% 0.066 53.813);
+ --color-yellow-100: oklch(42.1% 0.095 57.708);
+ --color-yellow-200: oklch(47.6% 0.114 61.907);
+ --color-yellow-300: oklch(55.4% 0.135 66.442);
+ --color-yellow-400: oklch(68.1% 0.162 75.834);
+ --color-yellow-500: oklch(79.5% 0.184 86.047);
+ --color-yellow-600: oklch(85.2% 0.199 91.936);
+ --color-yellow-700: oklch(90.5% 0.182 98.111);
+ --color-yellow-800: oklch(94.5% 0.129 101.54);
+ --color-yellow-900: oklch(97.3% 0.071 103.193);
+ --color-yellow-950: oklch(98.7% 0.026 102.212);
+ --color-indigo-50: oklch(25.7% 0.09 281.288);
+ --color-indigo-100: oklch(35.9% 0.144 278.697);
+ --color-indigo-200: oklch(39.8% 0.195 277.366);
+ --color-indigo-300: oklch(45.7% 0.24 277.023);
+ --color-indigo-400: oklch(51.1% 0.262 276.966);
+ --color-indigo-500: oklch(58.5% 0.233 277.117);
+ --color-indigo-600: oklch(67.3% 0.182 276.935);
+ --color-indigo-700: oklch(78.5% 0.115 274.713);
+ --color-indigo-800: oklch(87% 0.065 274.039);
+ --color-indigo-900: oklch(93% 0.034 272.788);
+ --color-indigo-950: oklch(96.2% 0.018 272.314);
+ --color-purple-50: oklch(29.1% 0.149 302.717);
+ --color-purple-100: oklch(38.1% 0.176 304.987);
+ --color-purple-200: oklch(43.8% 0.218 303.724);
+ --color-purple-300: oklch(49.6% 0.265 301.924);
+ --color-purple-400: oklch(55.8% 0.288 302.321);
+ --color-purple-500: oklch(62.7% 0.265 303.9);
+ --color-purple-600: oklch(71.4% 0.203 305.504);
+ --color-purple-700: oklch(82.7% 0.119 306.383);
+ --color-purple-800: oklch(90.2% 0.063 306.703);
+ --color-purple-900: oklch(94.6% 0.033 307.174);
+ --color-purple-950: oklch(97.7% 0.014 308.299);
+ --color-lime-50: oklch(27.4% 0.072 132.109);
+ --color-lime-100: oklch(40.5% 0.101 131.063);
+ --color-lime-200: oklch(45.3% 0.124 130.933);
+ --color-lime-300: oklch(53.2% 0.157 131.589);
+ --color-lime-400: oklch(64.8% 0.2 131.684);
+ --color-lime-500: oklch(76.8% 0.233 130.85);
+ --color-lime-600: oklch(84.1% 0.238 128.85);
+ --color-lime-700: oklch(89.7% 0.196 126.665);
+ --color-lime-800: oklch(93.8% 0.127 124.321);
+ --color-lime-900: oklch(96.7% 0.067 122.328);
+ --color-lime-950: oklch(98.6% 0.031 120.757);
+}
+
+/* White text and borders on coloured surfaces (buttons, badges) stay white */
+.dark .text-white, .dark .hover\:text-white:hover, .dark .fill-white { color: #fff; fill: #fff; }
+.dark .border-white { border-color: #fff; }
+/* Dark chips with white text (tooltip, compose header): the chip turns light, the text turns dark */
+.dark .bg-neutral-900.text-white, .dark .bg-neutral-800.text-white, .dark .bg-neutral-950.text-white { color: var(--color-neutral-50); }
+/* Buttons and highlights with white text keep their original saturated background, not the inverted one */
+.dark .bg-blue-600 { background-color: oklch(54.6% 0.245 262.881); }
+.dark .bg-blue-700, .dark .hover\:bg-blue-700:hover { background-color: oklch(48.8% 0.243 264.376); }
+.dark .bg-red-600 { background-color: oklch(57.7% 0.245 27.325); }
+.dark .bg-red-700, .dark .hover\:bg-red-700:hover { background-color: oklch(50.5% 0.213 27.518); }
+.dark .bg-green-600 { background-color: oklch(62.7% 0.194 149.214); }
+.dark .bg-amber-600 { background-color: oklch(66.6% 0.179 58.318); }
+.dark .bg-violet-600 { background-color: oklch(54.1% 0.281 293.009); }
+.dark .bg-teal-600 { background-color: oklch(60% 0.118 184.704); }
+.dark .bg-pink-600 { background-color: oklch(59.2% 0.249 0.584); }
+.dark .bg-orange-600 { background-color: oklch(64.6% 0.222 41.116); }
+/* Fixed-hex backgrounds (page, panels) and their hover: variants (inbox rows, mailbox selector) */
+.dark .bg-\[\#f6f8fc\], .dark .bg-\[\#f7f9fc\] { background-color: #202124; }
+.dark .bg-\[\#f2f6fc\], .dark .bg-\[\#f1f4fa\], .dark .bg-\[\#f0f3f9\] { background-color: #303134; }
+.dark .bg-\[\#eef3fb\], .dark .bg-\[\#eaf1fb\], .dark .bg-\[\#e6ecf6\] { background-color: #383a3e; }
+.dark .hover\:bg-\[\#f2f6fc\]:hover { background-color: #35363a; }
+.dark .hover\:bg-\[\#e6ecf6\]:hover { background-color: #3c4043; }
+/* Soft shadows turn dark */
+.dark .shadow-neutral-200, .dark .shadow-neutral-300 { --tw-shadow-color: rgb(0 0 0 / 0.6); }
+/* HTML emails assume a white background: keep them on light "paper" inside the dark theme */
+.dark .email-body {
+ color-scheme: light;
+ background: #fff;
+ color: #202124;
+ border-radius: 0.75rem;
+ padding: 1rem;
+}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 18c4a74..c6238d5 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { Providers } from "@/components/providers";
import { sidebarBootstrapScript } from "@/components/sidebar-state-utils";
+import { themeBootstrapScript } from "@/components/theme-utils";
import "./globals.css";
const geistSans = Geist({
@@ -36,12 +37,13 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return (
- <html lang="en">
+ <html lang="en" suppressHydrationWarning>
<head>
<script dangerouslySetInnerHTML={{ __html: sidebarBootstrapScript }} />
+ <script dangerouslySetInnerHTML={{ __html: themeBootstrapScript }} />
<link rel="icon" href="/api/branding/icon"></link>
</head>
- <body className={`${geistSans.variable} ${geistMono.variable} antialiased light`}>
+ <body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
<Providers>{children}</Providers>
</body>
</html>
diff --git a/src/components/providers.tsx b/src/components/providers.tsx
index 47f24d6..2bdca9d 100644
--- a/src/components/providers.tsx
+++ b/src/components/providers.tsx
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
import { clearMailboxClientState } from "@/components/mailbox-provider-utils";
import { BrandingProvider } from "@/components/branding-provider";
import { NewMessagePopup } from "@/components/new-message-popup";
+import { ThemeSync } from "@/components/theme-sync";
import { useMessagePolling } from "@/hooks/use-message-polling";
import { clearMessageClientState } from "@/hooks/utils";
import { clearMessageDetailCache } from "@/lib/messages/detail-cache";
@@ -43,6 +44,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
<QueryClientProvider client={client}>
<BrandingProvider>
{children}
+ <ThemeSync />
{realtime.notification && (
<NewMessagePopup
notification={realtime.notification}
diff --git a/src/components/settings/appearance-settings.tsx b/src/components/settings/appearance-settings.tsx
new file mode 100644
index 0000000..8c51b63
--- /dev/null
+++ b/src/components/settings/appearance-settings.tsx
@@ -0,0 +1,56 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { Select } from "@/components/ui/select";
+import {
+ isThemePreference,
+ readThemePreference,
+ saveThemePreference,
+ THEME_CHANGED_EVENT,
+ type ThemePreference,
+} from "@/components/theme-utils";
+
+const OPTIONS: { value: ThemePreference; label: string }[] = [
+ { value: "system", label: "Match system" },
+ { value: "light", label: "Light" },
+ { value: "dark", label: "Dark" },
+];
+
+export function AppearanceSettings() {
+ const [preference, setPreference] = useState<ThemePreference>("system");
+
+ useEffect(() => {
+ setPreference(readThemePreference());
+ const sync = () => setPreference(readThemePreference());
+ window.addEventListener(THEME_CHANGED_EVENT, sync);
+ return () => window.removeEventListener(THEME_CHANGED_EVENT, sync);
+ }, []);
+
+ return (
+ <label className="flex items-start gap-3 rounded-xl bg-neutral-50 p-4">
+ <span className="flex-1">
+ <span className="block text-sm font-medium text-neutral-900">Theme</span>
+ <span className="mt-1 block text-sm text-neutral-500">
+ Use a light or dark interface, or follow your system setting. Saved in this browser.
+ </span>
+ </span>
+ <Select
+ value={preference}
+ aria-label="Theme"
+ className="py-1.5 text-sm text-neutral-900"
+ onChange={(event) => {
+ const next = event.target.value;
+ if (!isThemePreference(next)) return;
+ setPreference(next);
+ saveThemePreference(next);
+ }}
+ >
+ {OPTIONS.map((option) => (
+ <option key={option.value} value={option.value}>
+ {option.label}
+ </option>
+ ))}
+ </Select>
+ </label>
+ );
+}
diff --git a/src/components/shortcuts/command-palette-item.tsx b/src/components/shortcuts/command-palette-item.tsx
index f603d97..7b950ef 100644
--- a/src/components/shortcuts/command-palette-item.tsx
+++ b/src/components/shortcuts/command-palette-item.tsx
@@ -26,7 +26,7 @@ export function CommandPaletteItem({
className={`w-full text-left px-3 py-2.5 rounded-xl flex items-center justify-between transition-colors ${
isActive
? "bg-blue-600 text-white"
- : "text-neutral-800 dark:text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800/70"
+ : "text-neutral-800 hover:bg-neutral-100"
}`}
>
<div className="flex items-center gap-3 min-w-0">
@@ -35,7 +35,7 @@ export function CommandPaletteItem({
className={`w-4 h-4 shrink-0 ${
isActive
? "text-white"
- : "text-neutral-500 dark:text-neutral-400"
+ : "text-neutral-500"
}`}
/>
)}
@@ -46,7 +46,7 @@ export function CommandPaletteItem({
className={`ml-2 text-xs truncate ${
isActive
? "text-blue-100"
- : "text-neutral-400 dark:text-neutral-500"
+ : "text-neutral-400"
}`}
>
{item.subtitle}
@@ -59,7 +59,7 @@ export function CommandPaletteItem({
className={`text-xs px-2 py-0.5 rounded-md font-mono font-medium shrink-0 ${
isActive
? "bg-blue-700 text-blue-100"
- : "bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 border border-neutral-200 dark:border-neutral-700"
+ : "bg-neutral-100 text-neutral-500 border border-neutral-200"
}`}
>
{item.shortcut}
diff --git a/src/components/shortcuts/command-palette.tsx b/src/components/shortcuts/command-palette.tsx
index 19f1cf4..138ad6f 100644
--- a/src/components/shortcuts/command-palette.tsx
+++ b/src/components/shortcuts/command-palette.tsx
@@ -69,11 +69,11 @@ function CommandPaletteDialog({
<div className="fixed inset-0 z-50 flex items-start justify-center pt-24 px-4 bg-neutral-900/40 backdrop-blur-xs animate-in fade-in duration-100">
<div className="fixed inset-0" onClick={onClose} aria-hidden="true" />
<div
- className="relative w-full max-w-xl bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-2xl shadow-2xl overflow-hidden flex flex-col z-10"
+ className="relative w-full max-w-xl bg-white border border-neutral-200 rounded-2xl shadow-2xl overflow-hidden flex flex-col z-10"
onKeyDown={handleKeyDown}
>
{/* Search header */}
- <div className="flex items-center px-4 py-3.5 border-b border-neutral-100 dark:border-neutral-800 gap-3">
+ <div className="flex items-center px-4 py-3.5 border-b border-neutral-100 gap-3">
<Search className="w-5 h-5 text-neutral-400" />
<input
ref={inputRef}
@@ -84,9 +84,9 @@ function CommandPaletteDialog({
setSelectedIndex(0);
}}
placeholder="Type a command or search actions..."
- className="w-full bg-transparent text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 text-[15px] focus:outline-none"
+ className="w-full bg-transparent text-neutral-900 placeholder-neutral-400 text-[15px] focus:outline-none"
/>
- <kbd className="px-2 py-0.5 text-xs font-semibold text-neutral-400 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-md shadow-2xs">
+ <kbd className="px-2 py-0.5 text-xs font-semibold text-neutral-400 bg-neutral-100 border border-neutral-200 rounded-md shadow-2xs">
ESC
</kbd>
</div>
@@ -127,10 +127,10 @@ function CommandPaletteDialog({
</div>
{/* Footer */}
- <div className="px-4 py-2.5 bg-neutral-50 dark:bg-neutral-950/60 border-t border-neutral-100 dark:border-neutral-800 flex items-center justify-between text-xs text-neutral-400">
+ <div className="px-4 py-2.5 bg-neutral-50 border-t border-neutral-100 flex items-center justify-between text-xs text-neutral-400">
<div className="flex items-center gap-3">
<span>
- <kbd className="px-1.5 py-0.5 bg-neutral-200 dark:bg-neutral-800 rounded mr-1 text-[10px]">
+ <kbd className="px-1.5 py-0.5 bg-neutral-200 rounded mr-1 text-[10px]">
↑↓
</kbd>
to navigate
diff --git a/src/components/shortcuts/shortcuts-help-dialog.tsx b/src/components/shortcuts/shortcuts-help-dialog.tsx
index dd1b0da..cbb9f5c 100644
--- a/src/components/shortcuts/shortcuts-help-dialog.tsx
+++ b/src/components/shortcuts/shortcuts-help-dialog.tsx
@@ -44,15 +44,15 @@ export function ShortcutsHelpDialog({
onClick={onClose}
aria-hidden="true"
/>
- <div className="relative w-full max-w-2xl bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-2xl shadow-2xl overflow-hidden flex flex-col z-10 max-h-[85vh]">
+ <div className="relative w-full max-w-2xl bg-white border border-neutral-200 rounded-2xl shadow-2xl overflow-hidden flex flex-col z-10 max-h-[85vh]">
{/* Header */}
- <div className="flex items-center justify-between px-6 py-4 border-b border-neutral-100 dark:border-neutral-800">
+ <div className="flex items-center justify-between px-6 py-4 border-b border-neutral-100">
<div className="flex items-center gap-2.5">
- <div className="p-1.5 bg-blue-50 dark:bg-blue-950/50 text-blue-600 rounded-lg">
+ <div className="p-1.5 bg-blue-50 text-blue-600 rounded-lg">
<Keyboard className="w-5 h-5" />
</div>
<div>
- <h2 className="text-base font-semibold text-neutral-900 dark:text-neutral-100">
+ <h2 className="text-base font-semibold text-neutral-900">
Keyboard Shortcuts
</h2>
<p className="text-xs text-neutral-400">
@@ -63,7 +63,7 @@ export function ShortcutsHelpDialog({
<button
type="button"
onClick={onClose}
- className="text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 p-1.5 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
+ className="text-neutral-400 hover:text-neutral-700 p-1.5 rounded-lg hover:bg-neutral-100 transition-colors"
>
<X className="w-5 h-5" />
</button>
@@ -73,7 +73,7 @@ export function ShortcutsHelpDialog({
<div className="overflow-y-auto p-6 grid grid-cols-1 md:grid-cols-2 gap-6">
{Object.entries(grouped).map(([category, items]) => (
<div key={category} className="space-y-3">
- <h3 className="text-xs font-semibold uppercase tracking-wider text-neutral-400 dark:text-neutral-500 border-b border-neutral-100 dark:border-neutral-800/80 pb-1.5">
+ <h3 className="text-xs font-semibold uppercase tracking-wider text-neutral-400 border-b border-neutral-100 pb-1.5">
{category}
</h3>
<div className="space-y-2">
@@ -82,10 +82,10 @@ export function ShortcutsHelpDialog({
key={idx}
className="flex items-center justify-between text-sm"
>
- <span className="text-neutral-700 dark:text-neutral-300">
+ <span className="text-neutral-700">
{item.label}
</span>
- <kbd className="px-2 py-0.5 text-xs font-mono font-medium text-neutral-600 dark:text-neutral-300 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-md shadow-2xs">
+ <kbd className="px-2 py-0.5 text-xs font-mono font-medium text-neutral-600 bg-neutral-100 border border-neutral-200 rounded-md shadow-2xs">
{formatKey(item)}
</kbd>
</div>
@@ -96,17 +96,17 @@ export function ShortcutsHelpDialog({
</div>
{/* Footer */}
- <div className="px-6 py-3 bg-neutral-50 dark:bg-neutral-950/60 border-t border-neutral-100 dark:border-neutral-800 flex items-center justify-between text-xs text-neutral-400">
+ <div className="px-6 py-3 bg-neutral-50 border-t border-neutral-100 flex items-center justify-between text-xs text-neutral-400">
<span>
Press{" "}
- <kbd className="px-1.5 py-0.5 bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded font-mono">
+ <kbd className="px-1.5 py-0.5 bg-neutral-200 text-neutral-700 rounded font-mono">
?
</kbd>{" "}
to toggle
</span>
<span>
Press{" "}
- <kbd className="px-1.5 py-0.5 bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded font-mono">
+ <kbd className="px-1.5 py-0.5 bg-neutral-200 text-neutral-700 rounded font-mono">
ESC
</kbd>{" "}
to close
diff --git a/src/components/theme-sync.tsx b/src/components/theme-sync.tsx
new file mode 100644
index 0000000..c0d6fef
--- /dev/null
+++ b/src/components/theme-sync.tsx
@@ -0,0 +1,22 @@
+"use client";
+
+import { useEffect } from "react";
+import { applyTheme, readThemePreference, THEME_CHANGED_EVENT } from "@/components/theme-utils";
+
+// Keeps the html class in step with the saved preference and, for "system", with the OS setting.
+export function ThemeSync() {
+ useEffect(() => {
+ const media = window.matchMedia("(prefers-color-scheme: dark)");
+ const sync = () => applyTheme(readThemePreference());
+ sync();
+ media.addEventListener("change", sync);
+ window.addEventListener(THEME_CHANGED_EVENT, sync);
+ window.addEventListener("storage", sync);
+ return () => {
+ media.removeEventListener("change", sync);
+ window.removeEventListener(THEME_CHANGED_EVENT, sync);
+ window.removeEventListener("storage", sync);
+ };
+ }, []);
+ return null;
+}
diff --git a/src/components/theme-utils.ts b/src/components/theme-utils.ts
new file mode 100644
index 0000000..96b141a
--- /dev/null
+++ b/src/components/theme-utils.ts
@@ -0,0 +1,54 @@
+export type ThemePreference = "light" | "dark" | "system";
+
+export const THEME_STORAGE_KEY = "mailflare-theme";
+export const THEME_CHANGED_EVENT = "mailflare:theme-changed";
+
+// Runs in <head> before paint, so the first frame already has the right theme (same approach as the
+// sidebar width). Keep it in sync with resolveTheme/applyTheme below.
+export const themeBootstrapScript = `(() => {
+ try {
+ const saved = localStorage.getItem("mailflare-theme");
+ const preference = saved === "light" || saved === "dark" ? saved : "system";
+ const dark = preference === "dark" || (preference === "system" && matchMedia("(prefers-color-scheme: dark)").matches);
+ document.documentElement.classList.toggle("dark", dark);
+ document.documentElement.classList.toggle("light", !dark);
+ } catch {}
+})();`;
+
+export function isThemePreference(value: unknown): value is ThemePreference {
+ return value === "light" || value === "dark" || value === "system";
+}
+
+export function readThemePreference(): ThemePreference {
+ if (typeof window === "undefined") return "system";
+ try {
+ const saved = localStorage.getItem(THEME_STORAGE_KEY);
+ return isThemePreference(saved) ? saved : "system";
+ } catch {
+ return "system";
+ }
+}
+
+export function resolveTheme(preference: ThemePreference): "light" | "dark" {
+ if (preference !== "system") return preference;
+ if (typeof window === "undefined") return "light";
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
+}
+
+export function applyTheme(preference: ThemePreference): void {
+ if (typeof document === "undefined") return;
+ const dark = resolveTheme(preference) === "dark";
+ document.documentElement.classList.toggle("dark", dark);
+ document.documentElement.classList.toggle("light", !dark);
+}
+
+export function saveThemePreference(preference: ThemePreference): void {
+ try {
+ if (preference === "system") localStorage.removeItem(THEME_STORAGE_KEY);
+ else localStorage.setItem(THEME_STORAGE_KEY, preference);
+ } catch {
+ // Storage can be unavailable in private windows; the theme still applies for this page.
+ }
+ applyTheme(preference);
+ if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent(THEME_CHANGED_EVENT, { detail: preference }));
+}
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
index a03239f..26cc023 100644
--- a/src/components/ui/badge.tsx
+++ b/src/components/ui/badge.tsx
@@ -8,9 +8,9 @@ const badgeVariants = cva(
variant: {
success: "border-transparent bg-green-600/10 text-green-600",
default:
- "border-transparent bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900",
+ "border-transparent bg-neutral-900 text-neutral-50",
secondary:
- "border-transparent bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",
+ "border-transparent bg-neutral-100 text-neutral-900",
outline: "bg-neutral-100 border-transparent",
},
},