MUI Extended UI Components

Theme Options


MUI's default

always expects complete
theme
object to override at any child level.

With
ThemeOptionsProvider

  • set the only required
    ThemeOptions
    at each level in Component Tree
  • change the themeOptions at runtime using the hook
    useThemeOptions().setThemeOptions()

Also Implements

Usage

  • ThemeOptionsProvider

    import { ThemeOptionsProvider } from "mui-extended"; // wrap all child components const component = ( <ThemeOptionsProvider themeOptions={themeOptions}> {children} </ThemeOptionsProvider> );

    Props :

    • themeOptions(Optional) theme options to be overrided
  • useThemeOptions
    to update the theme from inside the child components

    import { useThemeOptions } from "mui-extended"; import { ThemeOptions } from "@mui/material"; // within the child component const { setThemeOptions } = useThemeOptions(); const newThemeOptions: ThemeOptions = { palette: { primary: { main: "#0000ff" } } }; setThemeOptions(newThemeOptions); // updates primary main color to "#0000ff"
Demo
  • pallete.mode

  • palette.primary.main

  • components.MuiTextField.defaultProps.variant

  • components.MuiFormControl.defaultProps.size

Does this page need improvements?
Edit This Page in GitHub
Did this page help you?
Provide feedback in the GitHub Discussion Page
Need More help?

Write an email to opensource@sodaru.com