useTheme
Reference
useTheme()is the theme hook. It returns the active Protrak theme, includingcolorPalette(see color palette).- Use it to take the tenant's colors for charts and custom styling, for example as the first color for getDefaultColors.
- Call it at the top level of the widget function, like any React hook.
Returns
The theme object. The most used part for widgets is theme.colorPalette, for example theme.colorPalette.SECONDARY_DARK.
Usage Example
function Example() {
const { protrakComponents } = React.useContext(customWidgetContext);
const { useTheme } = protrakComponents;
const theme = useTheme();
return <div style={{ color: theme.colorPalette.SECONDARY_DARK }}>Themed text</div>;
}