Colors & Styles

Uranium UI Material Theme on MAUI uses Static Resources. It's best option for performance against dynamic resources. So, they can't be overriden in application. But they can be replaced entirely. Uranium UI provides a way to do it easily.

Replacing Resources

Best way to replace resources is putting files that include resources into Resources/Styles folder in your project. Then, you can override any resource by editing an existing resource in those files or creating a new one.

You can check the latest version and place it into yor project from GitHub repository:

Manual copying and placing into project it's not easiest way and it's not recommended. You can create those resource files in your project with dotnet CLI. UraniumUI.Templates already includes those files. So, you can create them with following command.

  • Run following command under /Resources/Styles folder
dotnet new uranium-material-resources -n MaterialOverride

That command will create MaterialOverrideColor.xaml and MaterialOverrideStyle.xaml files in your project. You can edit it and override any resource.

  • Then, go to App.xaml file and add those newly created resources. Final state should be like this:

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
        <ResourceDictionary Source="Resources/Styles/MaterialColorOverride.xaml" />
        <ResourceDictionary Source="Resources/Styles/Styles.xaml" />
        <ResourceDictionary Source="Resources/Styles/MaterialStyleOverride.xaml" />
    </ResourceDictionary.MergedDictionaries>
    

You can remove <material:ColorResource /> and <material:StyleResource /> declarions from App.xaml file if you configured them before. They're already included in your project now. But after removing them, you'll not be able to get updates. So, you have to update those files after each project update. You can consider keeping your customizations in a separate file.

In this document