cranpose_ui/widgets/spacer.rs
1//! Spacer widget implementation
2
3#![allow(non_snake_case)]
4
5use crate::composable;
6use crate::layout::policies::LeafMeasurePolicy;
7use crate::modifier::{Modifier, Size};
8use crate::widgets::Layout;
9use cranpose_core::NodeId;
10
11/// A component that represents an empty space.
12///
13/// # When to use
14/// Use `Spacer` to create empty space between other composables, or to push
15/// composables apart when using weighted arrangements in `Row` or `Column`.
16///
17/// # Arguments
18///
19/// * `size` - The explicit size of the spacer.
20///
21/// # Example
22///
23/// ```rust,ignore
24/// Row(..., || {
25/// Text("Left", Modifier::empty());
26/// Spacer(Size::new(16.0, 0.0)); // 16dp gap
27/// Text("Right", Modifier::empty());
28/// });
29/// ```
30#[composable]
31pub fn Spacer(size: Size) -> NodeId {
32 Layout(
33 Modifier::empty(),
34 LeafMeasurePolicy::new(size),
35 || {}, // No children
36 )
37}