reactjstypesmaterial-uithemes

How can I check the type of material ui theme in react js? (light or dark)


I want to create certain conditions based on whether the type of material ui theme is light or dark How can I do that?


Solution

  • The following does not work anymore:

    const isDarkTheme = useTheme().palette.type === 'dark';
    

    Try this Instead:

     const isDarkTheme = useTheme().palette.mode === 'dark';