Zephora UI

Tema

Tema ialah objek TypeScript biasa yang dikompil menjadi sifat tersuai CSS --z-*. Menukar tema menulis semula pemboleh ubah — serta-merta, tiada CSS-in-JS, tiada kos render semula untuk gaya.

Tema sedia buat

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",
});

Berskop (scoped) berbanding 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);

Penggantian pada peringkat CSS

Komponen membaca pemboleh ubah secara langsung, jadi mana-mana peraturan CSS boleh menema semula mana-mana subpokok:

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

Mod gelap

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