Component docs
Loading
"use client";
import { ThemeProvider } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
target | HTMLElement | null | — | Element that receives the theme. Omitted: <html>. null (a ref or state that is not set yet) applies nothing until an element arrives. |
theme | PixxlTheme | — | system follows prefers-color-scheme live. |
attribute | string | — | Extra attribute that mirrors the resolved theme for your own CSS ("class" toggles light/dark classes). Pixxl itself always reads data-theme, which is written regardless. |
children | ReactNode | — | — |
targetHTMLElement | null
Element that receives the theme. Omitted: <html>. null (a ref or state that is not set yet) applies nothing until an element arrives.
themePixxlTheme
system follows prefers-color-scheme live.
attributestring
Extra attribute that mirrors the resolved theme for your own CSS ("class" toggles light/dark classes). Pixxl itself always reads data-theme, which is written regardless.
childrenReactNode
// One element: target is null until the ref is set (nothing is applied yet).
const [target, setTarget] = useState<HTMLDivElement | null>(null);
<>
{/* Whole document. Several providers on <html> stack: the latest mounted wins. */}
<ThemeProvider theme="dark">...</ThemeProvider>
<div ref={setTarget}>
<ThemeProvider target={target} theme="dark">...</ThemeProvider>
</div>
</>