Temes
Els temes són objectes de TypeScript plans compilats en propietats personalitzades de CSS --z-*. Canviar de tema reescriu les variables — a l'instant, sense CSS-in-JS, sense cost de re-render per als estils.
Temes predefinits
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",
});Amb scope vs. 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);Sobreescriptures a nivell de CSS
Els components llegeixen les variables directament, així que qualsevol regla de CSS pot retematitzar qualsevol subarbre:
.marketing-section {
--z-primary: #ea580c;
--z-radius: 9999px;
}Mode fosc
const [scheme, setScheme] = useState<"light" | "dark">("light");
<ThemeProvider theme={scheme === "dark" ? darkTheme : lightTheme} global>
<App />
</ThemeProvider>