Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Features
- Access MaterialYou Dynamic Color Palette
- Automatically enables Android's EdgeToEdge StatusBar and NavigationBar Styling
Install
Install the Core plugin by adding the following to your Cargo.toml file:
src-tauri/Cargo.toml
[]
= { = "https://github.com/0xk1f0/tauri-plugin-m3" }
You can install the JavaScript Guest bindings like this:
Usage
First you need to register the core plugin with Tauri:
src-tauri/src/main.rs
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
import { colors } from "tauri-plugin-m3";
import type { ColorScheme } from "tauri-plugin-m3";
let colorScheme: ColorScheme = await colors();
console.log(colorScheme.primary); // Outputs color in RGBA format f.E. "#F4F678FF"
The following colors are available
type ColorScheme = {
primary?: string;
onPrimary?: string;
primaryContainer?: string;
onPrimaryContainer?: string;
inversePrimary?: string;
secondary?: string;
onSecondary?: string;
secondaryContainer?: string;
onSecondaryContainer?: string;
tertiary?: string;
onTertiary?: string;
tertiaryContainer?: string;
onTertiaryContainer?: string;
background?: string;
onBackground?: string;
surface?: string;
onSurface?: string;
surfaceVariant?: string;
onSurfaceVariant?: string;
inverseSurface?: string;
inverseOnSurface?: string;
outline?: string;
};
Global Theming
We can implement automatic global theming of our app via defining a fallback theme in our primary CSS file first
styles.css
}
Then initialize our colors when our app loads for the first time, f.E. in Svelte's onMount()
App.svelte
Hello World
This will ensure that our MaterialYou colors get loaded into our predefined CSS variables, but also provides a fallback theme.
Of course this is only one way to do it, feel free to use this plugin like you want! :)
Credits and Thanks
- plugins-workspace - For showing me how to build Tauri Plugins