Skip to content

WaveProvider

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.

BrandSuccessDanger
export const LightTheme: Story = {};

Dark Theme

Theme preview

Text, background and font come from WaveProvider; no inline colours are needed.

BrandSuccessDanger
export const DarkTheme: Story = {
  args: { theme: 'dark' },
};

High Contrast

Theme preview

Text, background and font come from WaveProvider; no inline colours are needed.

BrandSuccessDanger
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.

BrandSuccessDanger
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.

BrandSuccessDanger

Dark panel

Text, background and font come from WaveProvider; no inline colours are needed.

BrandSuccessDanger
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.

BrandSuccessDanger

Light panel, still right-to-left

Text, background and font come from WaveProvider; no inline colours are needed.

BrandSuccessDanger
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.

BrandSuccessDanger

Light preview

Text, background and font come from WaveProvider; no inline colours are needed.

BrandSuccessDanger
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

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

A link
Uploading files
  • Quarterly report
  • Budget (selected)
  • Roadmap
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

NameTypeRequiredDefaultDescription
theme'light' | 'dark' | 'high-contrast'Nothe 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'Nothe enclosing WaveProvider's direction, else 'ltr'

Text direction for the subtree (also read by portaled overlays and keyboard navigation).

portalContainerHTMLElement | nullNothe enclosing WaveProvider's container, else document.body

Element that portaled overlays (dialogs, popovers, menus, toasts) render into. null renders them into document.body, also inside a provider that sets a container.

inputDefaultsInputDefaultsNothe enclosing WaveProvider's defaults, else none (`medium`, `outline`)

Default size and appearance of the text inputs and pickers in the subtree (Input, Textarea, Select, SearchBox, SpinButton, Combobox, Dropdown, DatePicker, TimePicker, TagPicker). Their own props and a Field's size win. A nested provider merges its keys over the enclosing provider's; an omitted key is inherited.

motion'default' | 'none'Nothe enclosing WaveProvider's motion, else 'default'

Motion of the subtree. 'none' makes every motion slot below it (a part's motion, backdropMotion, expandIconMotion or indeterminateMotion left unset) behave as null, which also stops the slide of TabList's selection line, and turns off Carousel's slide or fade (a Carousel without its own motion) and the reveal of Nav item actions; a part's own value still wins. Transitions that are no motion slot keep running: the turn of Accordion's and Tree's chevrons, colour changes on hover and press. Fluent's MotionBehaviourProvider with 'skip' is the counterpart, which @fluentui/react-components does not export. A nested provider inherits an omitted motion like theme.

tokensWaveTokenOverrides | nullNothe enclosing WaveProvider's overrides, else none

Design token overrides for the subtree: CSS values by token name, the CSS variable in camelCase without its --wave- prefix (brand80 for --wave-brand-80, primaryForeground for --wave-primary-foreground; a number is written as its string). theme still names one of the three themes, and the overrides apply over it as inline custom properties on the root and on every portal of the subtree (see applyStylesToPortals), so its dialogs, menus, popovers, tooltips and toasts take them too. Fluent's theme prop with a partial theme is the counterpart.

A nested provider merges its overrides over the enclosing provider's, key by key: an omitted tokens inherits them all, and a key whose value is undefined inherits that key. null resets the subtree to the stylesheet's tokens: the inherited overrides of the tokens the theme declares (the semantic colours, shadows, palette) are cleared, and so are those of the theme-independent tokens (the brand and grey ramps, font families, stacking order, motion durations and curves), for which the root writes the stylesheet's own values (the library's: a re-brand of :root in your stylesheet that an enclosing provider overrode is not restored), also for the subtree's overlays. A nested provider that sets another theme inherits the overrides too, so set an override of a semantic colour (primary) in the provider that sets the theme it was chosen for. A whole brand ramp is better made with createBrandTokens than written by hand. A key that 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( whose quotes, parentheses, square brackets and comments are balanced, with no ! or backslash outside strings and comments; a well-formed name is not checked against the list of tokens (TypeScript refuses a misspelled one). In the server-rendered style attribute a refused character could add a declaration of its own, and an open string, comment or bracket, or an escape that spells url( or takes the semicolon after the value, would swallow the declarations after it (though not in the client), while !important would be a priority the client refuses. A value is trimmed as React's server renderer trims it, so the values that pass are written and read alike by the server and the client.

The overrides are rendered on the server too. Under a Content Security Policy that blocks inline style attributes (style-src without 'unsafe-inline'), the server-rendered overrides do not apply and hydration does not apply them again: ship them in a stylesheet there, and pass no tokens (nor getTokenStyle), since the overlays and the subtrees rendered in the client would still take them and leave the page half branded.

applyStylesToPortalsbooleanNothe enclosing WaveProvider's value, else true

Whether the portals of the subtree (dialogs, popovers, menus, tooltips, toasts) carry the overrides of tokens. false leaves them out: an overlay then shows its theme's own values for the tokens the theme declares, and keeps the surrounding cascade (that of the element it renders into) for the theme-independent ones. The theme classes and the direction are set on every portal either way, so an overlay of a dark provider is still dark. Fluent's applyStylesToPortals is the counterpart; unlike Fluent's, a nested provider inherits an omitted value, like theme.

classNamesWaveClassNames | nullNothe 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 ({ 'wave-button': 'rounded-full' } gives every Button, ToggleButton, MenuButton and other variant built on Button the class). The keys are the root classes of the stable class-name registry (wave-<name>, the class a component's root element carries; buttonClassNames.root), the values class lists written as your app writes classes. Fluent's customStyleHooks_unstable of FluentProvider is the counterpart, which Fluent keeps unstable.

The classes join the component's own after them and before the className of the instance, so className still wins a conflict, and a class of the same kind replaces Wave's: rounded-full replaces the Button's rounded-md. Only a component's root receives them: a part is styled with slotProps, and a stylesheet targets any stable class. A component rendered inside another carries its own root class, so an inner Button gets wave-button's classes too.

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, '' removes them): an omitted classNames inherits them all, and a key whose value is undefined inherits that key. null clears everything inherited. Without a provider no component reads or adds anything.

childrenReact.ReactNodeYes

Content rendered inside the themed container.

refReact.Ref<HTMLDivElement>No

Ref to the themed root <div>.

Any other prop is passed to the element it renders (HTMLDivElement).

Stable class names

PartClass
rootwave-root