Zephora UI

تم‌ها

تم‌ها آبجکت‌های ساده TypeScript هستند که به CSS custom properties با پیشوند --z-* کامپایل می‌شوند. تعویض تم متغیرها را بازنویسی می‌کند — بی‌درنگ، بدون CSS-in-JS، بدون هزینه re-render برای استایل‌ها.

تم‌های آماده

import { lightTheme, darkTheme, auraTheme, materialTheme } from "@zephora/theme";

createTheme

import { createTheme, lightTheme } from "@zephora/theme";

const brand = createTheme(lightTheme, {
  name: "brand",
  colors: {
    primary: "#0f766e",
    primaryHover: "#115e59",
    ring: "#14b8a6",
  },
  radius: "0.75rem",
});

Scoped در برابر global

// Scoped — wraps a subtree in a themed scope element
<ThemeProvider theme={brand}>...</ThemeProvider>

// Global — writes variables onto <html>, ideal for app-level switching
import { applyTheme } from "@zephora/theme";
applyTheme(brand);

بازنویسی در سطح CSS

کامپوننت‌ها متغیرها را مستقیماً می‌خوانند، بنابراین هر قاعده CSS می‌تواند هر زیردرخت را دوباره تم‌بندی کند:

.marketing-section {
  --z-primary: #ea580c;
  --z-radius: 9999px;
}

حالت تیره

const [scheme, setScheme] = useState<"light" | "dark">("light");
<ThemeProvider theme={scheme === "dark" ? darkTheme : lightTheme} global>
  <App />
</ThemeProvider>