CamoBreadcrumb
Concept
1. Why
A breadcrumb shows where you are in a hierarchy and lets you go up it: a folder path, a category trail (Fluent and Carbon's Breadcrumb, macOS path controls). The last item is the current location. When the trail is too long, the middle collapses into an overflow menu.
2. Shape
Split of duties
| Core | Skin (renderer) |
|---|---|
the items, measuring and collapsing the middle into a menu (the toolbar's fit logic and CamoMenuAnchor), separators, keys (Left and Right, Home, End), semantics (navigation, the current item) | the item look (link or text), the separator, the overflow button, spacing |
Material mapping preview: the M3 has none.
bodyMediumlinks inprimary, the current itemonSurface, a chevron separator.
3. API
Contract
data class CamoBreadcrumbItem(
val key: Any,
val label: String,
val icon: Slot? = null,
val onClick: (() -> Unit)? = null, // null: not a link
)
fun CamoBreadcrumb(
items: List<CamoBreadcrumbItem>, // root first; the last is the current location
maxVisible: Int? = null, // null: collapse only when it doesn't fit
label: String = "Breadcrumb",
)
State → renderer: BreadcrumbItemState(current, link, interaction), SeparatorState; the overflow is a ghost icon button from the skin plus CamoMenuAnchor. Slots: label, icon.
Tokens used
colors.primary(link),onSurface(current),onSurfaceVariant(separator)typography.bodyMedium;spacing.xs
Component theme
theme.components.breadcrumb. 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 |
|---|---|---|---|
separator | IconSource | chevron right | mirrors in RTL |
itemPadding | Dp | 4 | |
overflowIcon | IconSource | more | |
colors | BreadcrumbColors(link, current, separator, hover) | M3 values | every color it uses |
strings | BreadcrumbStrings | English | "More", "current page" |
Accessibility
- A navigation landmark named
label; links are buttons, the current item is announced "current page" and is not a button. - One Tab stop; Left and Right move, Enter activates, the overflow opens with Enter or Down.
4. Build steps
CamoBreadcrumbItem, the fit (reusing the toolbar's pure function), theme, state, renderer, theCamoSkinfield.CamoBreadcrumb, the DebugSkin renderer.- Tests: collapsing and the menu items,
maxVisible, keys, RTL, semantics.
Done when
- The admin sample's file tree has a breadcrumb that collapses on narrow windows.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Case | Decided behavior |
| --- | --- |
| One item | Just the current item. |
| A very long label | It ellipsizes; the first and last items keep at least a minimum width. |
| RTL | Order and separators mirror. |
- The renderer has
Container,ItemandSeparator; the overflow is the skin's ghost icon button with aCamoMenuAnchor.BreadcrumbColors(link, current, separator, hover); items are at least 48 tall for touch. - The fit is one pure function (
planBreadcrumb): everything when it fits (and withinmaxVisible), else the first item, the overflow and as many of the last items as fit. Below that shortest form the end is clipped. The current item is not a link and announces "current page". - Not built: built-in strings and per-item tooltips. Flutter measures the labels with
TextPainterin the ambient style (the current item semibold), keeps 8 px of slack and has no intrinsic size; a skin that adds more padding thanitemPaddingper item can make the estimate short.
- Which items collapse: the middle ones, keeping the first and the last two; say if you prefer only the last.
Implementation
1. Why
A SubcomposeLayout measures the items and decides what collapses, like the toolbar.
2. Shape
3. API
@Composable public fun CamoBreadcrumb(items: List<CamoBreadcrumbItem>, modifier: Modifier = Modifier,
maxVisible: Int? = null, label: String = "Breadcrumb")
4. Build steps
- Layout, items, overflow, renderer.
- Tests: collapsing, keys, semantics.
Done when
- Works by touch, mouse, keyboard and screen reader on all targets.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Measuring | The collapse needs the items' widths; they are measured once per label change. |
- A
SubcomposeLayoutmeasures silent copies of the items (their semantics cleared), then composes only what shows; the roving focus covers the shown parts.
- None specific.