StylishPopover

fun StylishPopover(expanded: Boolean, onExpandedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, anchor: @Composable () -> Unit, shape: Shape = RoundedCornerShape(DefaultStylishDimensions.connectedCornerRadius), containerColor: Color = MaterialTheme.colorScheme.surfaceContainerHigh, contentColor: Color = MaterialTheme.colorScheme.onSurface, contentPadding: PaddingValues = PaddingValues( horizontal = DefaultStylishDimensions.controlPadding, vertical = DefaultStylishDimensions.controlVerticalPadding, ), tonalElevation: Dp = DefaultStylishDimensions.floatingElevation, offset: Dp = 8.dp, width: Dp = 280.dp, properties: PopupProperties = PopupProperties(focusable = true), content: @Composable ColumnScope.() -> Unit)

A popover — anchored floating content for arbitrary use (filters, calendars, help text) — the MUI Popover / Radix Popover counterpart.

Unlike com.segnities007.stylishui.components.atoms.StylishDropdownMenu, a popover is not menu-shaped, does not auto-close when its content is tapped, and shows no scrim: it is dismissed only through onExpandedChange (typically by tapping outside, which triggers the popup's dismiss request). Content is laid out in a ColumnScope on a rounded, outlined, elevated surface sized to width, centered horizontally under the anchor and placed offset below it.

The anchor is rendered by this composable inside an internal Box. The popup enters with a short fade + scale animation (StylishTheme.animation.durationShort) that snaps instead of tweening when the platform requests reduced motion (see isStylishReducedMotionEnabled).

Anchoring limitation: the popup position is computed from the anchor's bounds while the popup is positioned relative to its enclosing box, so the anchor must not be nested inside transformed containers (e.g. parents that change the coordinate space, such as graphicsLayer scale/rotation or scroll-transformed layouts) or the popup will drift off the anchor.

var expanded by remember { mutableStateOf(false) }
StylishPopover(
expanded = expanded,
onExpandedChange = { expanded = it },
anchor = {
Button(onClick = { expanded = !expanded }) {
Text("フィルター")
}
},
) {
Text("カテゴリ", style = MaterialTheme.typography.titleSmall)
Text("写真のみ表示", style = MaterialTheme.typography.bodyMedium)
}

Testing

The popup surface carries the default test tag stylish_popover for UI tests. Callers can override it by passing their own Modifier.testTag(...) in modifier.

Parameters

expanded

Whether the popover is currently shown.

onExpandedChange

Called with false when the user requests dismissal (e.g. tapping outside); the caller should also toggle expanded when the anchor is tapped.

modifier

Modifier applied to the Box that wraps anchor.

anchor

The trigger composable the popover is anchored to, rendered inside the wrapping Box.

shape

Shape of the popup surface. Defaults to RoundedCornerShape with DefaultStylishDimensions.connectedCornerRadius (12 dp).

containerColor

Background color of the popup surface. Defaults to MaterialTheme.colorScheme.surfaceContainerHigh.

contentColor

Default content color inside the popup. Defaults to MaterialTheme.colorScheme.onSurface.

contentPadding

Padding around the content inside the popup. Defaults to the Stylish control paddings (16 dp horizontal, 12 dp vertical).

tonalElevation

Tonal elevation of the popup surface. Defaults to DefaultStylishDimensions.floatingElevation (2 dp).

offset

Vertical gap between the anchor's bottom edge and the popup's top edge. Defaults to 8 dp.

width

Width of the popup surface. Defaults to 280 dp.

properties

PopupProperties for further customization of the popup behavior. Defaults to a focusable popup.

content

The popup content, laid out in a ColumnScope.

See also