useMaterial3Theme(options?: UseMaterial3ThemeOptions): Object
Hook that lets you manage Material 3 theme in your app. It will return the theme retrieved from user device (or a fallback theme if device is not supported) or a theme based on a source color, a function to update the theme and a function to reset the theme.
```ts
// Without params
const { theme, updateTheme, resetTheme } = useMaterial3Theme();
// With params
const { theme, updateTheme, resetTheme } = useMaterial3Theme({ fallbackSourceColor: '#3E8260' });
// or
const { theme, updateTheme, resetTheme } = useMaterial3Theme({ sourceColor: '#3E8260' });
// or
const { theme, updateTheme, resetTheme } = useMaterial3Theme({
sourceColor: '#3E8260',
fallbackSourceColor: '#3E8260',
colorFidelity: true,
});
```
#### Parameters (optional)
{
theme: Material3Theme;
updateTheme: (sourceColor: string, options?: { colorFidelity?: boolean }) => void;
resetTheme: () => void;
}
getMaterial3Theme(fallbackSourceColor?: string, options?: Material3ThemeOptions): Material3Theme
Function that will return the theme retrieved from user device (or a fallback theme if device is not supported).
```ts
// Without params
const theme = getMaterial3Theme();
// With params
const theme = getMaterial3Theme('#6750A4');
// or
const theme = getMaterial3Theme('#6750A4', { colorFidelity: true });
```
#### Parameters
- `fallbackSourceColor` (optional, default to `#6750A4`): Source color for the fallback theme
- `options?: Material3ThemeOptions` (optional)
- `colorFidelity` (optional): Apply color fidelity to make scheme colors better match `fallbackSourceColor` if used
#### Returns
- [`Material3Theme`](../src/ExpoMaterial3Theme.types.ts#L59-L62): theme retrieved from user device (or fallback theme)
## getMaterial3ThemeAsync(fallbackSourceColor?: string, options?: Material3ThemeOptions): Promise<Material3Theme>
Function that will return the theme retrieved from user device (or a fallback theme if device is not supported) asynchronously.
It is an `AsyncFunction` "whose native code is by default dispatched on a different thread than the JavaScript runtime runs on" (https://docs.expo.dev/modules/module-api/#asyncfunction).
```ts
// Without params
const theme = await getMaterial3ThemeAsync();
// With params
const theme = await getMaterial3ThemeAsync('#6750A4');
// or
const theme = await getMaterial3ThemeAsync('#6750A4', { colorFidelity: true });
```
#### Parameters
- `fallbackSourceColor` (optional, default to `#6750A4`): Source color for the fallback theme
- `options?: Material3ThemeOptions` (optional)
- `colorFidelity` (optional): Apply color fidelity to make scheme colors better match `fallbackSourceColor` if used
#### Returns
- [`Material3Theme`](../src/ExpoMaterial3Theme.types.ts#L59-L62): theme retrieved from user device (or fallback theme)
createMaterial3Theme(sourceColor: string, options?: Material3ThemeOptions): Material3Theme
Function that will create a Material 3 theme based on a source color (using [`@material/material-color-utilities`](https://github.com/material-foundation/material-color-utilities/tree/main/typescript)).
```ts
const theme = createMaterial3Theme('#6750A4');
// With params
const theme = createMaterial3Theme('#6750A4', { colorFidelity: true });
```
#### Parameters
- `sourceColor` (required): Source color for the theme
- `options?: Material3ThemeOptions` (optional)
- `colorFidelity` (optional): Apply color fidelity to make scheme colors better match `sourceColor`
#### Returns
- [`Material3Theme`](../src/ExpoMaterial3Theme.types.ts#L59-L62): theme generated from the `sourceColor`