CamoDivider
Concept
1. Why
A divider separates groups of content in lists, menus, sheets and toolbars. It's the smallest component, but it's still themed: its color, thickness and inset come from tokens, so a brand that wants no dividers (or bold ones) changes one component theme instead of every screen.
2. Shape
Material mapping preview: M3 Divider: 1 dp, outlineVariant. Full-width, inset (start 16), or middle-inset (16 on both sides).
3. API
Contract
fun CamoDivider(
orientation: Orientation = Horizontal, // Horizontal | Vertical
inset: DividerInset = None, // None | Start | Middle
)
State → renderer: DividerState(orientation, inset). Slots: none.
Tokens used
colors.outlineVariantspacing.lfor insets
Component theme
theme.components.divider: DividerTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.
| Field | Type | Material default | What it's for |
|---|---|---|---|
thickness | Dp | 1 | line thickness |
color | Color | outlineVariant | line color |
startInset / endInset | Dp | 16 / 16 | the space used by Start and Middle insets |
Accessibility
- Decorative: hidden from screen readers. Grouping is conveyed by list sections and headings, not by dividers.
4. Build steps
CamoDivider,DividerTheme/Style,DividerRenderer, and the DebugSkin renderer.- Tests: no semantics node; thickness and color come from the style; a
Startinset mirrors in RTL.
Done when
- Horizontal and vertical dividers with all insets render in the sample, in light and dark.
5. Edge cases
| Case | Decided behavior |
|---|---|
| RTL | Start inset is on the right. |
| A vertical divider in a row without a fixed height | It takes the row's height (Compose: IntrinsicSize.Min; Flutter: IntrinsicHeight). The platform note shows how. |
| A brand with no dividers | DividerTheme(thickness = 0) or color = transparent, set once. |
Implementation
1. Why
The smallest component, and the simplest Kotlin note: a line whose color, thickness and insets come from DividerTheme. The only Compose-specific points are drawing it at exactly one logical pixel and keeping it out of the semantics tree.
2. Shape
3. API
@Composable
public fun CamoDivider(
modifier: Modifier = Modifier,
orientation: Orientation = Orientation.Horizontal, // androidx.compose.foundation.gestures.Orientation
inset: DividerInset = DividerInset.None, // None | Start | Middle
)
@Immutable public data class DividerState(val orientation: Orientation, val inset: DividerInset)
Rendering (DebugSkin and Minimal):
@Composable override fun Render(state: DividerState, theme: CamoTheme, style: DividerStyle, modifier: Modifier) {
val pad = when (state.inset) {
DividerInset.None -> PaddingValues(0.dp)
DividerInset.Start -> PaddingValues(start = style.insetStart)
DividerInset.Middle -> PaddingValues(horizontal = style.insetStart)
}
val line = if (state.orientation == Orientation.Horizontal)
Modifier.fillMaxWidth().height(style.thickness) else Modifier.fillMaxHeight().width(style.thickness)
Box(modifier.padding(pad).then(line).background(style.color).clearAndSetSemantics {})
}
style.thicknessis1.dp, one logical pixel, which is what the base asks for (not1.dp / density, which would vanish on some desktop displays).clearAndSetSemantics {}keeps the line out of TalkBack/VoiceOver traversal.- In a
RowwithIntrinsicSize.Min, a vertical divider takes the row's height.
4. Build steps
DividerTheme/DividerStyle,DividerInset,CamoDivider, the DebugSkin renderer.commonTest: the three insets produce the right padding in both layout directions; no semantics node; the vertical divider fills an intrinsic-height row.
Done when
- Horizontal, inset and vertical dividers render with theme colors on every target, and never appear in screen-reader traversal.
5. Edge cases
| Case | Decided behavior |
|---|---|
| RTL | PaddingValues(start = …) mirrors on its own. |
Vertical divider in a Row without an intrinsic height | It collapses to 0 height (Compose rule). The sample shows Row(Modifier.height(IntrinsicSize.Min)). |