WaveProvider
Applies Wave theming to an application or subtree.
- Renders a <div class="wave-root wave-<theme>"> that declares the theme's tokens and paints the themed background, text colour and font (bg-background text-foreground font-wave text-body-1; a className passed by you wins). The precompiled ./styles entry scopes its base styles and native-element reset to this root, so it is required there.
- Sets dir and data-wave-theme on the root. An unknown theme value (from untyped code) falls back to 'light' โ classes, data-wave-theme and the context value โ and warns once in development.
- Provides theme, direction, theme classes and the portal container through context, so portaled overlays render with the same theme and direction.
- Nests: a provider inherits every prop it omits (theme, dir, portalContainer) from the enclosing provider, so <WaveProvider theme="light"> inside an RTL app is a light panel that stays right-to-left and keeps the app's portal container. At the top level the defaults are 'light', 'ltr' and document.body.
- inputDefaults nests differently: a nested provider's defined keys override the enclosing provider's, and an omitted key is inherited, so setting only appearance in a nested provider keeps the enclosing provider's size.
- motion="none" turns the default motion of every animated part below it off (its motion slots, Carousel's slide, TabList's sliding line, the reveal of Nav item actions; a part's own motion still wins), while transitions without a slot keep running (Accordion's and Tree's chevron turns, colour changes); a nested provider inherits an omitted motion like theme.
- tokens overrides design tokens in the subtree with inline custom properties on the root (rendered on the server too) and on every portal of the subtree, unless applyStylesToPortals is false. A nested provider merges its overrides over the enclosing provider's key by key, also when it sets another theme; tokens={null} resets the subtree to the stylesheet's tokens, writing the stylesheet's own value of each theme-independent token that an enclosing provider overrode. An override whose key is not a camelCase identifier is skipped with a development warning, and so is a value unless it is a finite number or CSS text without ;, {, } or url( with balanced quotes, parentheses, square brackets and comments and no ! or backslash outside strings and comments; a value is trimmed as React's server renderer trims it, so the server and the client write the same overrides. Without overrides the root renders no style attribute unless you pass style.
Examples
Light Theme
Theme preview
Text, background and font come from WaveProvider; no inline colours are needed.
export const LightTheme: Story = {};Dark Theme
Theme preview
Text, background and font come from WaveProvider; no inline colours are needed.
export const DarkTheme: Story = {
args: { theme: 'dark' },
};High Contrast
Theme preview
Text, background and font come from WaveProvider; no inline colours are needed.
export const HighContrast: Story = {
args: { theme: 'high-contrast' },
};RTL
Right-to-left layout
Text, background and font come from WaveProvider; no inline colours are needed.
export const RTL: Story = {
args: { dir: 'rtl', children: <SampleContent title="Right-to-left layout" /> },
};Dark Inside Light
Light application
Text, background and font come from WaveProvider; no inline colours are needed.
Dark panel
Text, background and font come from WaveProvider; no inline colours are needed.
export const DarkInsideLight: Story = {
render: (args) => (
<WaveProvider {...args}>
<SampleContent title="Light application" />
<WaveProvider theme="dark" className="m-6 rounded-md border border-wave-border">
<SampleContent title="Dark panel" />
</WaveProvider>
</WaveProvider>
),
};Nested Inherits Direction
Dark right-to-left application
Text, background and font come from WaveProvider; no inline colours are needed.
Light panel, still right-to-left
Text, background and font come from WaveProvider; no inline colours are needed.
export const NestedInheritsDirection: Story = {
args: { theme: 'dark', dir: 'rtl' },
render: (args) => (
<WaveProvider {...args}>
<SampleContent title="Dark right-to-left application" />
<WaveProvider theme="light" className="m-6 rounded-md border border-wave-border">
<SampleContent title="Light panel, still right-to-left" />
</WaveProvider>
</WaveProvider>
),
};Light Inside Dark
Dark application
Text, background and font come from WaveProvider; no inline colours are needed.
Light preview
Text, background and font come from WaveProvider; no inline colours are needed.
export const LightInsideDark: Story = {
args: { theme: 'dark' },
render: (args) => (
<WaveProvider {...args}>
<SampleContent title="Dark application" />
<WaveProvider theme="light" className="m-6 rounded-md border border-wave-border">
<SampleContent title="Light preview" />
</WaveProvider>
</WaveProvider>
),
};Input Defaults
- Apple
- Banana
export const InputDefaults: Story = {
args: { inputDefaults: { size: 'small', appearance: 'filled-darker' } },
render: (args) => (
<WaveProvider {...args}>
<div className="flex flex-col gap-4 p-6">
<Field label="Name">
<Input placeholder="Type something..." />
</Field>
<Field label="Fruit">
<Combobox placeholder="Pick a fruit">
<Combobox.Option value="apple">Apple</Combobox.Option>
<Combobox.Option value="banana">Banana</Combobox.Option>
</Combobox>
</Field>
<Field label="Quantity">
<SpinButton defaultValue={1} />
</Field>
<WaveProvider inputDefaults={{ appearance: 'underline' }}>
<Field label="Underlined name (nested provider)">
<Input placeholder="Type something..." />
</Field>
</WaveProvider>
</div>
</WaveProvider>
),
};Brand colour
export const BrandColour: Story = {
name: 'Brand colour',
args: { tokens: violetRamp },
render: ({ children: _children, ...args }) => (
<WaveProvider {...args}>
<BrandSample />
</WaveProvider>
),
};Nested accent with a dialog
This example opens a dialog or panel. Use the button to show it.
export const NestedAccentWithADialog: Story = {
name: 'Nested accent with a dialog',
parameters: accentStoryParameters,
render: ({ children: _children, ...args }) => (
<WaveProvider {...args}>
<AccentDialogs />
</WaveProvider>
),
};Portals without styles
This example opens a dialog or panel. Use the button to show it.
export const PortalsWithoutStyles: Story = {
name: 'Portals without styles',
args: { applyStylesToPortals: false },
parameters: accentStoryParameters,
render: ({ children: _children, ...args }) => (
<WaveProvider {...args}>
<AccentDialogs />
</WaveProvider>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
theme | 'light' | 'dark' | 'high-contrast' | No | the enclosing WaveProvider's theme, else 'light' | Visual theme applied to the subtree. Providers can be nested in any order: each root declares its theme's tokens, so a light panel inside a dark app (and the reverse) renders correctly. |
dir | 'ltr' | 'rtl' | No | the enclosing WaveProvider's direction, else 'ltr' | Text direction for the subtree (also read by portaled overlays and keyboard navigation). |
portalContainer | HTMLElement | null | No | the enclosing WaveProvider's container, else document.body | Element that portaled overlays (dialogs, popovers, menus, toasts) render into. |
inputDefaults | InputDefaults | No | the enclosing WaveProvider's defaults, else none (`medium`, `outline`) | Default |
motion | 'default' | 'none' | No | the enclosing WaveProvider's motion, else 'default' | Motion of the subtree. |
tokens | WaveTokenOverrides | null | No | the enclosing WaveProvider's overrides, else none | Design token overrides for the subtree: CSS values by token name, the CSS variable in camelCase without its A nested provider merges its overrides over the enclosing provider's, key by key: an omitted The overrides are rendered on the server too. Under a Content Security Policy that blocks inline style attributes ( |
applyStylesToPortals | boolean | No | the enclosing WaveProvider's value, else true | Whether the portals of the subtree (dialogs, popovers, menus, tooltips, toasts) carry the overrides of |
classNames | WaveClassNames | null | No | the enclosing WaveProvider's classes, else none | App-wide classes by component: the classes a component with that root class receives wherever it renders in the subtree, portaled overlays included ( The classes join the component's own after them and before the A nested provider merges its map over the enclosing provider's, key by key (a key it sets replaces the enclosing provider's classes for that component, |
children | React.ReactNode | Yes | Content rendered inside the themed container. | |
ref | React.Ref<HTMLDivElement> | No | Ref to the themed root |
Any other prop is passed to the element it renders (HTMLDivElement).
Stable class names
| Part | Class |
|---|---|
root | wave-root |