Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

1.9 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

// Apply the stored theme before first paint. External classic script since CSP is script-src 'self'.
try {
  // Guarded reads so blocked localStorage still falls back to the OS preference.
  var theme = "system";
  var palette = null;
  try {
    theme = localStorage.getItem("theme") || "system";
    palette = localStorage.getItem("palette");
  } catch (e) {}
  var dark =
    theme === "dark" ||
    (theme !== "light" && matchMedia("(prefers-color-scheme: dark)").matches);
  var root = document.documentElement;
  root.classList.toggle("dark", dark);
  root.classList.toggle("light", !dark);
  root.style.colorScheme = dark ? "dark" : "light";
  // Keep in sync with COLOR_THEME_IDS ("standard" sets no attribute).
  var palettes = [
    "blueberry", "butterfly-pea", "cherry",
    "cinnamon", "cotton-candy", "dragon-fruit", "earl-grey", "espresso",
    "honey", "licorice", "macaron", "matcha", "mint", "neon-cyberpunk",
    "oat-milk", "peach", "pina-paraiso", "plum", "tangerine", "taro",
    "wasabi", "yuzu", "trick-or-treat",
  ];
  if (palettes.indexOf(palette) !== -1) {
    root.setAttribute("data-palette", palette);
  }
} catch (e) {}

// macOS defaults the UI font to the system font (index.css html.client-mac); set before
// first paint so Inter never flashes. Follows the browser OS, not the possibly remote server.
try {
  if (/Macintosh/.test(navigator.userAgent)) {
    document.documentElement.classList.add("client-mac");
  }
} catch (e) {}

// One screen pixel in CSS px, for slider tracks (index.css); re-run when the zoom changes.
try {
  (function px() {
    var r = devicePixelRatio || 1;
    document.documentElement.style.setProperty("--device-px", 1 / r + "px");
    matchMedia("(resolution:" + r + "dppx)").addEventListener("change", px, { once: true });
  })();
} catch (e) {}