pub fn surface(
args: SurfaceArgs,
ripple_state: Option<RippleState>,
child: impl FnOnce(),
)Expand description
§surface
Renders a styled container for content with optional interaction.
§Usage
Wrap content to provide a visual background, shape, and optional click handling with a ripple effect.
§Parameters
args— configures the surface’s appearance, layout, and interaction; seeSurfaceArgs.ripple_state— an optional, clonableRippleStateto enable and manage the ripple animation on click.child— a closure that renders the content inside the surface.
§Examples
use std::sync::Arc;
use tessera_ui::{Dp, Color};
use tessera_ui_basic_components::{
surface::{surface, SurfaceArgsBuilder},
ripple_state::RippleState,
text::{text, TextArgsBuilder},
};
let ripple = RippleState::new();
surface(
SurfaceArgsBuilder::default()
.padding(Dp(16.0))
.on_click(Arc::new(|| println!("Surface was clicked!")))
.build()
.unwrap(),
Some(ripple),
|| {
text(TextArgsBuilder::default().text("Click me".to_string()).build().expect("builder construction failed"));
},
);