Function surface

Source
pub fn surface(
    args: SurfaceArgs,
    ripple_state: Option<Arc<RippleState>>,
    child: impl FnOnce(),
)
Expand description

A basic container component that provides a customizable background, optional shadow, border, shape, and interactive ripple effect. The surface is typically used to wrap content and visually separate it from the background or other UI elements.

If args.on_click is set, the surface becomes interactive and displays a ripple animation on click. In this case, a RippleState must be provided to manage the ripple effect and hover state.

§Parameters

  • args: SurfaceArgs struct specifying appearance, layout, and interaction.
  • ripple_state: Optional RippleState for interactive surfaces. Required if on_click is set.
  • child: Closure that builds the child content inside the surface.

§Example

use std::sync::Arc;
use tessera_ui::{Color, Dp};
use tessera_ui_basic_components::{
    pipelines::ShadowProps,
    surface::{surface, SurfaceArgs},
    text::text,
};

surface(
    SurfaceArgs {
        color: Color::from_rgb(1.0, 1.0, 1.0),
        shadow: Some(ShadowProps::default()),
        padding: Dp(12.0),
        ..Default::default()
    },
    None,
    || {
        text("Content in a surface".to_string());
    },
);