ThemeProvider class
The ThemeProvider class provides the capability to get different themes from the Framework. Themes can be provided in different contexts, e.g. Canvas sections may provide a variant of the global theme in some contexts.
Constructors
(constructor)(service |
Construct a new instance of the ThemeProvider class. |
Properties
service |
The service key for ThemeProvider. |
Methods
try |
If set, get the current scoped theme. |
try |
Events
theme |
Raised when the theme changes with the new theme as an argument. |
Constructor Details
(constructor)(serviceScope, theme, themeV2)
Construct a new instance of the ThemeProvider class.
constructor(serviceScope: ServiceScope, theme?: ITheme, themeV2?: Theme);
Parameters
- serviceScope
- ServiceScope
The current service scope.
- theme
- ITheme
Theme to provide.
- themeV2
- @fluentui/tokens!Theme:type
Property Details
serviceKey
The service key for ThemeProvider.
static readonly serviceKey: ServiceKey<ThemeProvider>;
Property Value
Method Details
tryGetTheme()
If set, get the current scoped theme.
tryGetTheme(): IReadonlyTheme | undefined;
Returns
IReadonlyTheme | undefined
tryGetThemeV2()
tryGetThemeV2(): Theme | undefined;
Returns
@fluentui/tokens!Theme:type | undefined
Event Details
themeChangedEvent
Raised when the theme changes with the new theme as an argument.
readonly themeChangedEvent: SPEvent<ThemeChangedEventArgs>;