Skip to content

Popover - Frameworks

A Popover is a message box that is displayed floating over page content after pressing a trigger element, like an info-icon.

AndroidreleasedElementsreleasedReactreleasedVuereleased

Android

Syntax

kotlin
@Composable
fun WarpPopover(
    modifier: Modifier = Modifier,
    title: String,
    body: String,
    state: WarpPopoverState,
    edge: Edge = Edge.Top,
    horizontalOffset: Dp = 0.dp,
    verticalOffset: Dp = 0.dp,
    inline: Boolean = false,
    dismissPopoverOnClickOutside: Boolean = true,
    onDismiss: () -> Unit = {},
    anchorView: @Composable (() -> Unit)? = null,
)

Visual options

The popover will be displayed as a popup and its arrow will be pointing towards the center of the anchor view, the edge - direction in which the popover will be pointing - must be provided as a param. It is also possible to place the popover as you wish by setting the inline param to true.

kotlin
val topState = remember { WarpPopoverState(false) }

WarpPopover(
    modifier = Modifier.padding(horizontal = dimensions.space1),
    state = topState,
    title = "Top Popover",
    body = "Top Popover body text",
    edge = Edge.Top
) {
    WarpButton(
        text = "Top Popover",
        onClick = { topState.isVisible = !topState.isVisible })
}

Usage

Use the WarpPopoverState class to toggle between show & hide. Use the Edge class to choose the arrow direction. When using the inline Popover, no anchor is needed, you place the Popover as any Composable.

kotlin

class WarpPopoverState(isVisible: Boolean = false) {
    var isVisible: Boolean by mutableStateOf(isVisible)
}

enum class Edge {
    Top,
    Bottom,
    Leading,
    Trailing
}

Legacy support

Not supported

Parameters

Required props

NameTypeDefaultDescription
titleStringThe text to be displayed in the popover
bodyStringThe text to be displayed in the popover
stateWarpPopoverStateThe state of the popover. If visible or not

Optional Props

NameTypeDefaultDescription
modifierModifierModifierModifier for the popover
edgeEdge.Top Edge.Bottom Edge.Leading Edge.TrailingEdge.TopEdge that determines the direction of the arrow
horizontalOffsetDp0.dpHorizontal offset for the popover
verticalOffsetDp0.dpVertical offset for the popover
inlineBooleanfalseShows the popover as a standalone inline view
dismissPopoverOnClickOutsideBooleantrueIf should dismiss the popover when clicked outside it
onDismiss() -> Unit{}The lambda to be invoked when dismissed
anchorView@Composable () -> UnitnullThe anchor which the popover points to

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system