Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor(ui): mark dark as beta in the theme menu, not the toolbar (#37680)

ryan-crabbe-berri787edb123f85
diff --git a/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.test.tsx b/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.test.tsx
index 3f7af94bfa0..41efedcd43a 100644
--- a/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.test.tsx
+++ b/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.test.tsx
@@ -16,7 +16,7 @@ const openMenu = async () => {
await screen.findByRole("menu");
};
-const pick = async (label: string) => userEvent.click(screen.getByRole("menuitemradio", { name: label }));
+const pick = async (label: string | RegExp) => userEvent.click(screen.getByRole("menuitemradio", { name: label }));
beforeEach(() => {
localStorage.clear();
@@ -33,7 +33,7 @@ describe("ThemeToggle", () => {
await openMenu();
expect(screen.getByRole("menuitemradio", { name: "Light" })).toBeChecked();
- expect(screen.getByRole("menuitemradio", { name: "Dark" })).not.toBeChecked();
+ expect(screen.getByRole("menuitemradio", { name: /^Dark/ })).not.toBeChecked();
expect(screen.getByRole("menuitemradio", { name: "System" })).not.toBeChecked();
});
@@ -41,7 +41,7 @@ describe("ThemeToggle", () => {
renderToggle();
await openMenu();
- await pick("Dark");
+ await pick(/^Dark/);
expect(document.documentElement).toHaveClass("dark");
expect(localStorage.getItem("theme")).toBe("dark");
@@ -50,7 +50,7 @@ describe("ThemeToggle", () => {
it("hands control back to the system preference when asked", async () => {
renderToggle();
await openMenu();
- await pick("Dark");
+ await pick(/^Dark/);
await pick("System");
@@ -58,15 +58,20 @@ describe("ThemeToggle", () => {
expect(document.documentElement).not.toHaveClass("dark");
});
- it("flags dark mode as experimental, and only while it is on", async () => {
+ it("marks dark as beta in the menu, and leaves the other choices unmarked", async () => {
renderToggle();
await openMenu();
- expect(screen.queryByText("Experimental")).not.toBeInTheDocument();
- await pick("Dark");
- expect(screen.getByText("Experimental")).toBeInTheDocument();
+ expect(screen.getByRole("menuitemradio", { name: /^Dark/ })).toHaveTextContent("Beta");
+ expect(screen.getByRole("menuitemradio", { name: "Light" })).not.toHaveTextContent("Beta");
+ expect(screen.getByRole("menuitemradio", { name: "System" })).not.toHaveTextContent("Beta");
+ });
+
+ it("keeps the beta marker inside the menu rather than in the toolbar", async () => {
+ renderToggle();
+ await openMenu();
+ await pick(/^Dark/);
- await pick("Light");
- expect(screen.queryByText("Experimental")).not.toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Theme" })).not.toHaveTextContent("Beta");
});
});
diff --git a/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.tsx b/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.tsx
index 6a006141523..3fbb3d2eb5b 100644
--- a/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.tsx
+++ b/ui/litellm-dashboard/src/components/ThemeToggle/ThemeToggle.tsx
@@ -15,46 +15,43 @@ import {
} from "@/components/ui/dropdown-menu";
const THEMES = [
- { value: "system", label: "System", Icon: Monitor },
- { value: "light", label: "Light", Icon: Sun },
- { value: "dark", label: "Dark", Icon: Moon },
+ { value: "system", label: "System", Icon: Monitor, beta: false },
+ { value: "light", label: "Light", Icon: Sun, beta: false },
+ { value: "dark", label: "Dark", Icon: Moon, beta: true },
] as const;
const ThemeToggle: React.FC = () => {
const { theme, setTheme, resolvedTheme } = useTheme();
- const isDark = resolvedTheme === "dark";
return (
- <span className="flex items-center gap-1">
- {isDark && (
- <Badge
- variant="outline"
- className="px-1.5 py-0 text-[10px] font-medium text-muted-foreground"
- title="Dark mode is still being rolled out, so some surfaces may not be styled yet"
- >
- Experimental
- </Badge>
- )}
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button variant="ghost" size="icon-sm" aria-label="Theme" title="Theme" className="text-muted-foreground" />
- }
- >
- {isDark ? <Moon /> : <Sun />}
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-36">
- <DropdownMenuRadioGroup value={theme ?? "light"} onValueChange={setTheme}>
- {THEMES.map(({ value, label, Icon }) => (
- <DropdownMenuRadioItem key={value} value={value}>
- <Icon />
- {label}
- </DropdownMenuRadioItem>
- ))}
- </DropdownMenuRadioGroup>
- </DropdownMenuContent>
- </DropdownMenu>
- </span>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="ghost" size="icon-sm" aria-label="Theme" title="Theme" className="text-muted-foreground" />
+ }
+ >
+ {resolvedTheme === "dark" ? <Moon /> : <Sun />}
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-40">
+ <DropdownMenuRadioGroup value={theme ?? "light"} onValueChange={setTheme}>
+ {THEMES.map(({ value, label, Icon, beta }) => (
+ <DropdownMenuRadioItem key={value} value={value}>
+ <Icon />
+ {label}
+ {beta && (
+ <Badge
+ variant="secondary"
+ className="px-1 py-0 text-[10px] font-medium text-muted-foreground"
+ title="Dark mode is still being rolled out, so some surfaces may not be styled yet"
+ >
+ Beta
+ </Badge>
+ )}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
);
};