Skip to main content

Box

Function Box 

Source
pub fn Box<F>(__arg0: Modifier, __arg1: BoxSpec, __arg2: F) -> NodeId
where F: FnMut() + 'static,
Expand description

Places children over the same area. content_alignment selects each child’s position within the box; later children draw above earlier children.

§Example

use cranpose_ui::*;

#[composable]
fn Badge() {
    Box(
        Modifier::empty()
            .size_points(100.0, 100.0)
            .background(Color(0.1, 0.3, 0.9, 1.0)),
        BoxSpec::default().content_alignment(Alignment::CENTER),
        || {
            Text("Centered", Modifier::empty(), TextStyle::default());
        },
    );
}