Reflex Logo

Intro

Gallery

Hosting

Components

New

Learn

Components

API Reference

Onboarding

Library

/

Overlay

/

Popover

A popover displays content, triggered by a button.

The popover.root contains all the parts of a popover.

The popover.trigger contains the button that toggles the popover.

The popover.content is the component that pops out when the popover is open.

The popover.close is the button that closes an open popover.

rx.popover.root(
    rx.popover.trigger(
        rx.button("Popover"),
    ),
    rx.popover.content(
        rx.flex(
            rx.text("Simple Example"),
            rx.popover.close(
                rx.button("Close"),
            ),
            direction="column",
            spacing="3",
        ),
    ),
)
rx.popover.root(
    rx.popover.trigger(
        rx.button("Comment", variant="soft"),
    ),
    rx.popover.content(
        rx.flex(
            rx.avatar("2", fallback="RX", radius="full"),
            rx.box(
                rx.text_area(
                    placeholder="Write a comment…",
                    style={"height": 80},
                ),
                rx.flex(
                    rx.checkbox("Send to group"),
                    rx.popover.close(
                        rx.button("Comment", size="1")
                    ),
                    spacing="3",
                    margin_top="12px",
                    justify="between",
                ),
                flex_grow="1",
            ),
            spacing="3",
        ),
        style={"width": 360},
    ),
)
rx.popover.root(
    rx.popover.trigger(
        rx.button("Feedback", variant="classic"),
    ),
    rx.popover.content(
        rx.inset(
            side="top",
            background="url('https://source.unsplash.com/random/800x600') center/cover",
            height="100px",
        ),
        rx.box(
            rx.text_area(
                placeholder="Write a comment…",
                style={"height": 80},
            ),
            rx.flex(
                rx.checkbox("Send to group"),
                rx.popover.close(
                    rx.button("Comment", size="1")
                ),
                spacing="3",
                margin_top="12px",
                justify="between",
            ),
            padding_top="12px",
        ),
        style={"width": 360},
    ),
)

Floating element for displaying rich content, triggered by a button.

PropTypeDescriptionValues
openbool

The controlled open state of the popover.

modalbool

The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers.

Event Triggers

TriggerDescription
on_open_change

The on_open_change event handler is called when the open state of the component changes.

Contains content to be rendered in the open popover.

PropTypeDescriptionValues
sizeLiteral

Size of the button: "1" | "2" | "3" | "4"

sideLiteral

The preferred side of the anchor to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.

side_offsetint

The distance in pixels from the anchor.

alignLiteral

The preferred alignment against the anchor. May change when collisions occur.

align_offsetint

The vertical distance in pixels from the anchor.

avoid_collisionsbool

When true, overrides the side andalign preferences to prevent collisions with boundary edges.

Event Triggers

TriggerDescription
on_open_auto_focus

The on_open_auto_focus event handler is called when the component opens and the focus is returned to the first item.

on_close_auto_focus

The on_close_auto_focus event handler is called when focus moves to the trigger after closing. It can be prevented by calling event.preventDefault.

on_escape_key_down

The on_escape_key_down event handler is called when the escape key is down. It can be prevented by calling event.preventDefault.

on_pointer_down_outside

The on_pointer_down_outside event handler is called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.

on_focus_outside

The on_focus_outside event handler is called when the user focuses outside the component.

on_interact_outside

The on_interact_outside event handler is called when the user interacts outside the component.

Wraps the control that will open the popover.

Props

No component specific props

Wraps the control that will close the popover.

Props

No component specific props

← HovercardTooltip →

Did you find this useful?

HomeGalleryChangelogIntroductionHosting