Skip to main content

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.outlineVariant
  • spacing.l for 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.

FieldTypeMaterial defaultWhat it's for
thicknessDp1line thickness
colorColoroutlineVariantline color
startInset / endInsetDp16 / 16the 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​

  1. CamoDivider, DividerTheme/Style, DividerRenderer, and the DebugSkin renderer.
  2. Tests: no semantics node; thickness and color come from the style; a Start inset mirrors in RTL.

Done when

  • Horizontal and vertical dividers with all insets render in the sample, in light and dark.

5. Edge cases​

CaseDecided behavior
RTLStart inset is on the right.
A vertical divider in a row without a fixed heightIt takes the row's height (Compose: IntrinsicSize.Min; Flutter: IntrinsicHeight). The platform note shows how.
A brand with no dividersDividerTheme(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.thickness is 1.dp, one logical pixel, which is what the base asks for (not 1.dp / density, which would vanish on some desktop displays).
  • clearAndSetSemantics {} keeps the line out of TalkBack/VoiceOver traversal.
  • In a Row with IntrinsicSize.Min, a vertical divider takes the row's height.

4. Build steps​

  1. DividerTheme / DividerStyle, DividerInset, CamoDivider, the DebugSkin renderer.
  2. 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​

CaseDecided behavior
RTLPaddingValues(start = …) mirrors on its own.
Vertical divider in a Row without an intrinsic heightIt collapses to 0 height (Compose rule). The sample shows Row(Modifier.height(IntrinsicSize.Min)).