Skip to main content

CamoToolbar

Concept​

1. Why​

A toolbar is a row of actions for the current context: formatting buttons in an editor, a bottom bar of a message list, a floating toolbar over a canvas (Material docked and floating toolbars and the bottom app bar, Apple's toolbars, Fluent's Toolbar). It is not navigation (that is the bar, rail and drawer) and not a title bar (CamoTopBar). Actions that don't fit move into an overflow menu.

2. Shape​

Split of duties

CoreSkin (renderer)
the action model, overflow measuring and the overflow menu (reusing CamoMenuAnchor), roving focus and the toolbar role, insets for the docked bottom placementcontainer color, shape, depth, spacing, the action look (icon, icon + label), the separator

Material mapping preview: the M3 docked and floating toolbars.

  • Docked: 64 tall, surfaceContainer, full width. Floating: 64 tall, shapes.full, level3, detached by 16.
  • Actions are 48 icon buttons in onSurfaceVariant; the overflow is a "⋮" at the end.

3. API​

Contract​

data class CamoToolbarAction(
val key: Any,
val label: String, // names the action, shows in the overflow menu and beside the icon when asked
val icon: Widget,
val onClick: () -> Unit,
val enabled: Boolean = true,
val selected: Boolean? = null, // non-null → a toggle (Bold, Italic): pressed state
val tone: Tone = Default,
)

fun CamoToolbar(
actions: List<CamoToolbarAction>,
placement: ToolbarPlacement = Docked, // Docked | Floating
leading: Widget? = null, // a menu button, a title
trailing: Widget? = null, // a FAB-like primary action
overflowLabel: String = "More",
)

// building block (ADR-30): the skin's toolbar surface, the toolbar role and arrow keys, for custom content
fun CamoToolbarContainer(placement: ToolbarPlacement = Docked, content: Slot)

Overflow: actions are measured in order; those that don't fit collapse into a trailing "⋮" CamoMenuAnchor whose items are the actions' labels, icons and toggles. CamoButtonGroups and CamoSplitButtons can also be placed in leading/trailing or in the container.

State → renderer: ToolbarState(placement, count, overflowing). The renderer draws the container; each action is drawn by skin.iconButton (a toggle uses its checked look) unless the skin's ToolbarRenderer.Action overrides. Slots: ToolbarSlots(leading?, trailing?).

Tokens used​

  • colors.surfaceContainer, onSurfaceVariant, outlineVariant
  • shapes.full (floating), elevation.level3 (floating)
  • spacing.s between actions, spacing.l side padding
  • motion.durationShort (a floating toolbar shows and hides)

Component theme​

theme.components.toolbar: ToolbarTheme?. 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
placementDocked | FloatingDockeddocked: edge to edge on the inset; floating: detached
heightDp64toolbar height (plus the bottom inset when docked at the bottom)
floatingMargin / floatingShapeDp / Shape16 / shapes.fullthe floating container
floatingElevationElevationLevelLevel3the floating depth
showLabelsLabelVisibilityNeverlabels beside icons (Apple and Fluent can show them)
actionSpacingDp4between actions
showDividerBooleanfalsea hairline on the docked edge
colorsToolbarColors(container, icon, selected, divider)surfaceContainer, onSurfaceVariant, primary, outlineVariantevery color it uses

Accessibility​

  • Role toolbar, named by the app (contentDescription/semanticLabel), with the actions as buttons ("Bold, toggle button, pressed").
  • One Tab stop; the arrow keys move between actions, Home and End jump, and a disabled action is skipped.
  • The overflow button announces "More, has popup" and its items are menu items.

4. Build steps​

  1. CamoToolbarAction, the measuring overflow, ToolbarTheme / Style, state, slots, renderer, the CamoSkin field.
  2. CamoToolbar, CamoToolbarContainer, the DebugSkin renderer.
  3. Sample: an editor toolbar with grouped and split buttons, a popover and a properties side sheet (the milestone screen).
  4. Tests: overflow at narrow widths (and back), toggles, roving focus, the menu items, the bottom inset, floating placement.

Done when

  • The editor sample's toolbar overflows gracefully, works by touch, keyboard and screen reader.

5. Edge cases​

CaseDecided behavior
Nothing fitsOnly the overflow button shows.
Vertical toolbarsLater (orientation).
A toggle in the overflowA checkable menu item with the same state.
Hide on scrollvisible like the bar and the FAB (rememberHideOnScroll).
Changed in the M9 build (2026-11-02)
  • The renderer has one part, the container: Container(state, theme, style, modifier, content) with ToolbarState(placement, count). The actions are ghost skin.iconButtons and core measures and lays out the row; there is no ToolbarSlots and no overflowing flag, because the fit is known only after the container is drawn.
  • The theme gains actionSize (the width one action takes when measuring), padding and overflowIcon; ToolbarColors is (container, divider). showLabels is not built (labels beside icons come later).
  • Overflow: all actions, or as many as fit beside the overflow button, in order; the rest become menu items with their labels, icons, tones and enabled state, and a toggle becomes a checkable item. Arrow keys move over the actions and the overflow button without pressing them.
  • Neither Compose nor Flutter has a toolbar role: the toolbar is a named container. It measures its room as it lays out, so it has no intrinsic size; give it a width.
  • Not built: insets for a docked bottom toolbar, hide on scroll (visible), vertical toolbars, tooltips on the actions. Minimal draws a 48 bar with a hairline (floating: Level2); Fluent a flat 44 bar (floating: Level4).
  • Actions as data vs. children: the data form gives automatic overflow; custom children (button groups, split buttons) go in leading/trailing or the building-block container and do not overflow. Say if you want children to overflow too (it needs a measured custom layout).
  • Vertical toolbars are Later.

Implementation​

1. Why​

Compose has no toolbar below Material's. Core measures with a SubcomposeLayout to decide which actions fit, draws those with the skin's icon button and moves the rest into the overflow menu.

2. Shape​

3. API​

@Composable public fun CamoToolbar(actions: List<CamoToolbarAction>, modifier: Modifier = Modifier,
placement: ToolbarPlacement = ToolbarPlacement.Docked, leading: (@Composable () -> Unit)? = null,
trailing: (@Composable () -> Unit)? = null, overflowLabel: String = "More", visible: Boolean = true)
@Composable public fun CamoToolbarContainer(modifier: Modifier = Modifier, placement: ToolbarPlacement = Docked,
content: @Composable RowScope.() -> Unit)
  • SubcomposeLayout measures every action once, reserves the overflow button and the leading and trailing slots, and composes only the actions that fit; resizing recomposes the split.
  • Roving focus (rememberRovingFocus) across the fitting actions and the overflow button; Role.Button, and toggleable for toggles.
  • Docked placement pads by the bottom navigation-bar inset; visible slides it like the navigation bar.

4. Build steps​

  1. The overflow layout, ToolbarTheme / Style, state, slots, renderer, the CamoSkin field.
  2. CamoToolbar, CamoToolbarContainer, the DebugSkin renderer.
  3. Tests: overflow at widths, toggle semantics, arrows, the inset, the menu items.

Done when

  • Overflow, toggles and keyboard work on all targets.

5. Edge cases​

CaseDecided behavior
Window resizeThe split recomputes; focus stays on the same action when it is still visible, else on the overflow button.
RTLThe row and the overflow mirror.
Changed in the M9 build (2026-11-02)
  • Measuring is a SubcomposeLayout: the leading and trailing content are measured first, the actions are composed last with fitActions(count, available, action, spacing) (a pure function, tested alone). Each action is a CamoIconButton with rovingFocusItem; the overflow is a CamoMenuAnchor over the rest.
  • CamoToolbarContainer(modifier, placement, contentDescription, content) is the building block. Tests: the fit function, overflow at narrow widths and back, toggles in the toolbar and in the overflow, arrows skipping a disabled action, leading and trailing content, the floating placement.
  • Sample: the editor screen (a command bar in a CamoToolbarContainer with a split button and two groups, a floating action bar with a popover and a properties side sheet).
  • None specific.