Skip to content

Divider

Divider is a basic layout component in COUI used to separate content in lists and layouts. It provides both horizontal and vertical divider styles.

Import

kotlin
import io.github.suqi8.coui.kmp.basic.HorizontalDivider // Horizontal divider
import io.github.suqi8.coui.kmp.basic.VerticalDivider   // Vertical divider

Basic Usage

Horizontal Divider

Horizontal divider is used to separate vertically arranged content:

kotlin
Column {
    Text("Content Above")
    HorizontalDivider()
    Text("Content Below")
}

Vertical Divider

Vertical divider is used to separate horizontally arranged content:

kotlin
Row {
    Text("Left Content")
    VerticalDivider()
    Text("Right Content")
}

Properties

HorizontalDivider Properties

Property NameTypeDescriptionDefault ValueRequired
modifierModifierModifier applied to the dividerModifierNo
thicknessDpThickness of the dividerDividerDefaults.ThicknessNo
colorColorColor of the dividerDividerDefaults.DividerColorNo

VerticalDivider Properties

Property NameTypeDescriptionDefault ValueRequired
modifierModifierModifier applied to the dividerModifierNo
thicknessDpThickness of the dividerDividerDefaults.ThicknessNo
colorColorColor of the dividerDividerDefaults.DividerColorNo

DividerDefaults Object

The DividerDefaults object provides default values for the divider components.

Constants

Constant NameTypeDescriptionDefault Value
ThicknessDpDefault thickness of divider0.33.dp
DividerColorColorDefault color of dividerCOUITheme.colorScheme.dividerLine
CardInsetDpRecommended horizontal inset inside a Card (COUI rule)16.dp

Advanced Usage

Custom Thickness Divider

kotlin
Column {
    Text("Content Above")
    HorizontalDivider(
        thickness = 2.dp
    )
    Text("Content Below")
}

Custom Color Divider

kotlin
Column {
    Text("Content Above")
    HorizontalDivider(
        color = Color.Red
    )
    Text("Content Below")
}

Divider Between Card Rows

Following the COUI card list rule, place a divider only between adjacent rows inside a card (never after the last row) and inset it by DividerDefaults.CardInset on both sides. For rows with a leading icon, increase the start inset so the divider aligns with the title text start:

kotlin
Card {
    BasicComponent(title = "First Row")
    HorizontalDivider(
        modifier = Modifier.padding(horizontal = DividerDefaults.CardInset)
    )
    BasicComponent(title = "Second Row")
}

Using Vertical Divider Between Buttons

kotlin
Row(
    horizontalArrangement = Arrangement.SpaceBetween,
    verticalAlignment = Alignment.CenterVertically
) {
    Button(onClick = { /* Handle click event */ }) {
        Text("Cancel")
    }
    VerticalDivider(
        modifier = Modifier.height(24.dp)
    )
    Button(onClick = { /* Handle click event */ }) {
        Text("Confirm")
    }
}

Changelog

Released under the Apache-2.0 License