Skip to main content

AmbientProvider

AmbientProvider applies theme values by writing Ambient CSS variables as inline styles on a wrapping <div>, scoping the theme to its own subtree rather than the whole document.

Interactive preview​

Warm Theme
Drive

Props​

PropTypeNotes
themeAmbientThemeOptional global light/theme overrides.
classNamestringWrapper class.
styleCSSPropertiesWrapper inline style.
childrenReactNodeWrapped app content.

AmbientTheme​

FieldType
lightXnumber
lightYnumber
keyLightnumber
fillLightnumber
lightHuenumber
lightSaturationnumber
highlightColorstring
lumeHuenumber

Example​

import { AmbientProvider } from "@ambientcss/components";

export function AppTheme({ children }: { children: React.ReactNode }) {
return (
<AmbientProvider
theme={{
lightX: -1,
lightY: -1,
keyLight: 0.9,
fillLight: 0.72,
lightHue: 220,
lightSaturation: 14,
highlightColor: "#7dd3fc",
lumeHue: 190
}}
>
{children}
</AmbientProvider>
);
}