Skip to main content

CamoPopover

Concept​

1. Why​

A popover is a non-modal panel anchored to a control, for content that is richer than a menu and lighter than a dialog: a few lines of text, a small form, an inline picker, one or two actions (Apple's popover, Fluent's Popover and TeachingPopover, Material's rich tooltip). Unlike a dialog it doesn't dim the screen, and unlike a menu its content is arbitrary. It opens next to its anchor, closes on an outside tap or Esc, and hands focus back to the anchor.

2. Shape​

Split of duties

Core (popover)Skin (renderer)
anchoring and edge flipping (the anchored-popup primitive, ADR-30), the open state, outside tap and Esc, focus in and back, semanticscontainer color, shape and depth, the arrow, title and action placement, padding

Material mapping preview: the M3 rich tooltip (there is no popover in Material).

  • Container surfaceContainer, shapes.medium, level2, max width 320.
  • Title titleSmall, body bodyMedium in onSurfaceVariant, actions as ghost buttons at the end.
  • No arrow.

3. API​

Contract​

fun CamoPopover(
open: Boolean,
onDismissRequest: () -> Unit,
anchor: Slot, // the element the popover points at; it stays in the layout
title: String? = null,
actions: Slot? = null, // buttons at the bottom end (CamoButton Ghost / Solid)
placement: PopoverPlacement = Auto, // Auto | Bottom | Top | Start | End
content: Slot, // arbitrary layout content
)

// building block (ADR-30): the skin's popover surface and semantics for content you position yourself
fun CamoPopoverPanel(title: String? = null, actions: Slot? = null, content: Slot)

Visibility is state (open), not a route: the app's button toggles it, like every controlled component (ADR-30). Auto opens below the anchor, flips above when there is no room, and tries the sides when asked (Start/End). The renderer is told where the anchor is so it can draw an arrow.

State → renderer: PopoverState(placement, arrowOffset) (placement is the one actually used after flipping; arrowOffset is where the anchor's center is along the edge, for the arrow). Slots: PopoverSlots(title?, content, actions?).

Tokens used​

  • colors.surfaceContainer, onSurface, onSurfaceVariant, outlineVariant (the hairline skins draw)
  • shapes.medium, elevation.level2, typography.titleSmall / bodyMedium
  • spacing.l padding, spacing.s between title, content and actions
  • motion.durationShort (scale and fade in from the anchor side)

Component theme​

theme.components.popover: PopoverTheme?. 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
shapeShapeshapes.mediumcontainer corners
maxWidthDp320the widest the panel gets
paddingPadding16around the content
showArrowBooleanfalsean arrow pointing at the anchor (Apple and Fluent: true)
arrowSizeSize16 × 8the arrow
elevationElevationLevelLevel2depth
titleStyleCamoTextStyletitleSmallthe title
gapDp8space between anchor and panel
colorsPopoverColors(container, title, content, border?)surfaceContainer, onSurface, onSurfaceVariant, noneevery color it uses

Accessibility​

  • The anchor announces "has popup" and expanded or collapsed.
  • The panel is a non-modal group named by its title; it is announced when it opens.
  • Keyboard: opening moves focus into the panel (the first focusable child, or the panel itself); Tab stays inside while it is open; Esc closes it and returns focus to the anchor. An outside tap or the screen-reader dismiss action closes it.
  • It never traps a pointer: taps outside close it and still reach what is under them only when the app wants that (default: they just close it).

4. Build steps​

  1. PopoverPlacement and the placement rules on the anchored-popup primitive (side placement, the arrow offset).
  2. CamoPopover, CamoPopoverPanel, PopoverRenderer, the DebugSkin renderer.
  3. Sample: a popover from a toolbar button with a title, a small form and two actions.
  4. Tests: open and close by tap, outside tap and Esc; focus in and back; placement flips at the window edge; the arrow follows the anchor; semantics.

Done when

  • A popover opens from a button, closes on an outside tap or Esc, returns focus to its anchor, and reads as a group.

5. Edge cases​

CaseDecided behavior
Not enough room on any sideIt is clamped inside the window and may overlap the anchor; the arrow still points at the anchor's center.
The anchor scrolls awayThe popover follows the anchor while it is visible and closes through onDismissRequest when the anchor leaves the viewport.
A popover inside a popover or a dialogAllowed; each closes on its own Esc, innermost first.
Touch devicesSame behavior; the outside tap closes it. On phones, a bottom sheet is usually the better presentation, and the app chooses.
Rich tooltip (hover)Later (CamoRichTooltip on the same panel).
  • Controlled only? open is state, with no uncontrolled trigger helper in v0.1 (a button's onClick toggles it). A CamoPopoverAnchor { toggle -> … } convenience like the menu's is cheap to add if you want it.
  • Arrow default: off in the core default, on for Apple and Fluent, per their guidelines.
Changed in the M9 build (2026-11-02)
  • PopoverState(placement, arrowOffset): placement is the side it really opened on after flipping, and arrowOffset is where the anchor's center is along the panel's edge (from its top for the side placements, from its left for above and below). The arrow is drawn by the renderer in a margin of arrowSize.height on the facing edge, so the gap between the anchor and the panel includes it.
  • Placement is one pure function (below, then above; the side asked for, then the opposite, then below; centered on the anchor and kept inside the window) so it is tested without a window.
  • The anchor must be one control: its semantics are merged to announce "has popup", expanded or collapsed.
  • Opening and closing are state changes the app makes; an outside tap, back and Esc only call onDismissRequest. Focus moves into the panel when it opens and back to the anchor when it closes.
  • The panel follows its anchor when the page scrolls (Flutter) and is placed again on a resize. Minimal draws a hairline panel with no arrow; Fluent a panel with shadow16 and an arrow.

Implementation​

1. Why​

Compose's Popup is the primitive; core's anchored popup already flips below or above and handles outside taps and Esc for menus. The popover adds side placement, the arrow offset, and the controlled open.

2. Shape​

3. API​

@Composable
public fun CamoPopover(
open: Boolean,
onDismissRequest: () -> Unit,
anchor: @Composable () -> Unit,
modifier: Modifier = Modifier,
title: String? = null,
actions: (@Composable RowScope.() -> Unit)? = null,
placement: PopoverPlacement = PopoverPlacement.Auto,
content: @Composable ColumnScope.() -> Unit,
)
  • The anchor sits in a Box; the popup is positioned from its bounds by a PopupPositionProvider that returns the chosen PopoverPlacement back through state, so the renderer draws the arrow on the right edge.
  • PopupProperties(focusable = true, dismissOnClickOutside = true, dismissOnBackPress = true); Esc through onPreviewKeyEvent. Focus moves in with a FocusRequester, and when open becomes false core requests focus on the anchor (the anchor modifier carries a FocusRequester).
  • Semantics: the anchor gets stateDescription and a popup action; the panel paneTitle = title and isTraversalGroup.

4. Build steps​

  1. PopoverPlacement, the position provider, PopoverTheme / Style, state, slots, renderer, the CamoSkin field.
  2. CamoPopover, CamoPopoverPanel, the DebugSkin renderer.
  3. Tests: open and close by outside tap, back and Esc; focus returns to the anchor; the flip at the bottom edge; the side placements and RTL (Start and End mirror); the arrow offset.

Done when

  • The Compose sample's popover works by touch, mouse, keyboard and screen reader on all targets.

5. Edge cases​

CaseDecided behavior
open flips while the anchor recomposesThe popup is keyed on open; no flicker.
RTLStart and End mirror.
Reduced motionThe scale-in becomes instant (the provider's reduced motion).
  • None specific.