Skip to main content

repose_material/material3/
divider.rs

1#![allow(non_snake_case)]
2
3use repose_core::*;
4use repose_ui::Box;
5
6use super::*;
7
8/// Configuration for divider components.
9#[derive(Clone, Debug)]
10pub struct DividerConfig {
11    pub modifier: Modifier,
12    pub thickness: f32,
13    pub color: Color,
14}
15
16impl Default for DividerConfig {
17    fn default() -> Self {
18        Self {
19            modifier: Modifier::new(),
20            thickness: DividerDefaults::THICKNESS,
21            color: DividerDefaults::color(),
22        }
23    }
24}
25
26/// M3 Horizontal Divider - a thin 1dp line.
27/// (Equivalent to Compose Material3's `HorizontalDivider`.)
28pub fn HorizontalDivider(config: DividerConfig) -> View {
29    Box(Modifier::new()
30        .min_width(200.0)
31        .height(config.thickness)
32        .background(config.color)
33        .then(config.modifier))
34}
35
36#[deprecated(since = "0.19.5", note = "renamed to HorizontalDivider")]
37pub fn Divider(config: DividerConfig) -> View {
38    HorizontalDivider(config)
39}
40
41/// M3 Vertical Divider - a thin 1dp vertical line.
42pub fn VerticalDivider(config: DividerConfig) -> View {
43    Box(Modifier::new()
44        .width(config.thickness)
45        .fill_max_height()
46        .background(config.color)
47        .then(config.modifier))
48}