Provides a theme to its descendant components through Lit context.

Use it to scope a theme to a part of the page. The library components in the provider use its theme instead of the global theme.

Element
igc-theme-provider
Slots
default — The content that receives the provided theme.

Remarks

Register the theme provider before the descendant components that consume the theme context. Then the context provider is available when the descendant components request it.

import { defineComponents, IgcThemeProviderComponent, IgcButtonComponent } from 'igniteui-webcomponents';

// Register theme provider first, then descendant components
defineComponents(IgcThemeProviderComponent, IgcButtonComponent);

The provider changes the styles of the components only. The colors, the typography and the elevations are CSS custom properties that the theme file sets on :root. To change them for the content of the provider too, set them on the provider, for example with the palette(), typography() and elevations() mixins of igniteui-theming in a selector. The host renders as display: contents, but its content still inherits them.

Example

<!-- Scope material theme to a section -->
<igc-theme-provider theme="material" variant="dark">
  <igc-button>Material Dark Button</igc-button>
  <igc-input label="Material Dark Input"></igc-input>
</igc-theme-provider>

<!-- Use different theme in another section -->
<igc-theme-provider theme="fluent" variant="light">
  <igc-button>Fluent Light Button</igc-button>
</igc-theme-provider>

The theme to provide to descendant components.

theme: "material" | "bootstrap" | "indigo" | "fluent" = 'bootstrap'

Defined in src/components/theme-provider/theme-provider.ts:81

The theme variant to provide to descendant components.

variant: "light" | "dark" = 'light'

Defined in src/components/theme-provider/theme-provider.ts:90

Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.

Note on Content Security Policy:

Element styles are implemented with <style> tags when the browser doesn't support adopted StyleSheets. To use such <style> tags with the style-src CSP directive, the style-src value must either include 'unsafe-inline' or nonce-<base64-value> with <base64-value> replaced be a server-generated nonce.

To provide a nonce to use on generated <style> elements, set window.litNonce to a server-generated nonce in your page's HTML, before loading application code:

``

styles: CSSResult

Defined in src/components/theme-provider/theme-provider.ts:53