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