Skip to main content

repose_material/material3/
divider.rs

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