Skip to main content

material_theme

Function material_theme 

Source
pub fn material_theme() -> MaterialThemeBuilder
Expand description

§material_theme

Provides a Material theme context (color scheme, typography, shapes) to descendants.

§Usage

Wrap your app (or a subtree) to configure defaults for Material components. The theme producer reads current state on each rebuild and updates descendants when its result changes.

§Parameters

  • theme — optional theme producer for descendants.
  • child — optional content rendered with the provided theme.

§Examples

use tessera_components::theme::{
    MaterialColorScheme, MaterialTheme, MaterialTypography, material_theme,
};
use tessera_ui::{Color, tessera};

#[tessera]
fn app() {
    let scheme = MaterialColorScheme::light_from_seed(Color::from_rgb(0.4, 0.3, 0.6));
    let typography = MaterialTypography::default();

    material_theme()
        .theme(move || MaterialTheme {
            color_scheme: scheme.clone(),
            typography,
            ..MaterialTheme::default()
        })
        .child(|| {
            // Your UI here.
        });
}