useTheme()
Home > @gooddata/sdk-ui-theme-provider > useTheme
useTheme() function
Hook for reaching the theme from context.
Signature:
useTheme: (theme?: ITheme) => ITheme | undefined
Parameters
Parameter | Type | Description |
---|---|---|
theme | ITheme | (Optional) theme to use instead of context value. If undefined, the context value is used. |
Returns:
ITheme | undefined
Remarks
You can optionally set a theme override that will be returned if defined. This makes the usage more ergonomic (see the following example).
Example
// instead of
const fromContext = useTheme();
const effectiveTheme = fromArguments ?? fromContext.
// you can write
const theme = useTheme(fromArguments);