Skip to main content
Ctrl+K
Panel Material UI v0.17.0 - Home Panel Material UI v0.17.0 - Home
  • How-To
  • Component Gallery
  • Release Notes
  • GitHub
  • Twitter
  • Discourse
  • Discord
  • How-To
  • Component Gallery
  • Release Notes
  • GitHub
  • Twitter
  • Discourse
  • Discord

FOR USERS

  • How-To
    • Customize Themes & Styles
    • Customize Color Palettes
    • Customize Typography
    • Theme Components
    • Control Dark Mode
    • Pick Colors
    • Use Icons
    • Build Custom Components
    • Apply Branding
    • Theme Plotting Libraries
  • Component Gallery
    • Widgets
      • AutocompleteInput
      • Avatar
      • Button
      • CheckBoxGroup
      • CheckButtonGroup
      • Checkbox
      • Chip
      • ColorMap
      • ColorPicker
      • CrossSelector
      • DatePicker
      • DateRangePicker
      • DateRangeSlider
      • DateSlider
      • DatetimePicker
      • DatetimeRangePicker
      • DatetimeRangeSlider
      • DatetimeSlider
      • DiscretePlayer
      • DiscreteSlider
      • EditableFloatSlider
      • EditableIntRangeSlider
      • EditableIntSlider
      • EditableRangeSlider
      • Fab
      • FileDownload
      • FileInput
      • FileSelector
      • FloatInput
      • FloatSlider
      • IconButton
      • IntInput
      • IntRangeSlider
      • IntSlider
      • LiteralInput
      • MultiChoice
      • MultiPill
      • MultiSelect
      • NestedSelect
      • PasswordInput
      • Pill
      • Player
      • RadioBoxGroup
      • RadioButtonGroup
      • RangeSlider
      • Rating
      • Select
      • StaticText
      • Switch
      • TextAreaInput
      • TextInput
      • TimePicker
      • Toggle
      • ToggleIcon
    • Menus
      • Breadcrumbs
      • MenuBar
      • MenuButton
      • MenuList
      • MenuToggle
      • NestedBreadcrumbs
      • Pagination
      • SpeedDial
      • SplitButton
      • StepperMenu
      • TabMenu
      • Tree
    • Layouts
      • Accordion
      • Alert
      • Backdrop
      • Card
      • Container
      • Details
      • Dialog
      • Drawer
      • Feed
      • FlexBox
      • FloatPanel
      • Grid
      • Paper
      • Popup
      • Tabs
    • Panes
      • Typography
    • Wrappers
      • Badge
      • Clickable
      • Fullscreen
      • Skeleton
      • Tooltip
      • Transition
    • Page
      • AppBar
      • BreakpointSwitcher
      • Manual
      • Page
      • ThemeToggle
    • Chat
      • ChatAreaInput
      • ChatFeed
      • ChatInterface
      • ChatMessage
      • ChatStep
    • Indicators
      • CircularProgress
      • LinearProgress
    • Global
      • Notifications
      • Reveal
  • Release Notes
HoloViz.org
  • hvPlot
  • HoloViews
  • GeoViews
  • Datashader
  • Param
  • Lumen
  • Colorcet

  • Examples Gallery
  • Blog
  • Component Gallery
  • Layouts
  • Popup

Popup#

Download this notebook from GitHub (right-click to download).


import panel as pn
from panel_material_ui import Button, Column, IconButton, Popup, Row

pn.extension()

The Popup component displays content in an anchored overlay that requires user interaction. It is commonly used for contextual menus, confirmations, forms, or any UI element that should appear relative to another component or screen position.

Parameters#

For more details on customization, see the customization guides.

Core#

  • open (boolean): Whether the popup is visible.

  • close_on_click (boolean): Whether clicking outside the popup should close it.

  • enforce_focus (boolean): Whether focus is locked inside the popup while open.

  • hide_backdrop (boolean): Whether to hide the backdrop behind the popup.

  • label (str): Accessible name of the popup. When set, screen readers announce the popup as a dialog with this name.

  • modal (boolean): Whether the popup is modal (default True). With modal=False it behaves as a non-modal dialog, see below.

Positioning#

  • anchor_origin (dict): The vertical and horizontal alignment relative to the anchor (default: {"horizontal": "right", "vertical": "bottom"}).

  • anchor_position (XYCoordinates): Absolute x/y coordinates to anchor the popup to.

  • elevation (int): Elevation level of the popup surface. Defaults to 1 for a modal popup and to 8, like menus, for a non-modal one.

Styling#

  • sx (dict): Component-level styling options.

  • theme_config (dict): Theming options.


Basic Usage#

The Popup can be programmatically opened and closed by setting the open parameter:

open = Button(label='Open')
close = Button(label='Close')

popup = Popup('# This is a popup', close, open=True)

open.js_on_click(args={'popup': popup}, code="popup.data.open = true")
close.js_on_click(args={'popup': popup}, code="popup.data.open = false")

Column(open, popup).preview(height=200, width=400)

Here we set up a jslink to toggle open but you can toggle it programmatically:

popup.open = True

Positioning#

By default the component is anchored to its parent element, alternatively it can be attached to another element:

popup = Popup("# An anchored Popup", open=True)
help_button = IconButton(icon="help", attached=[popup])

help_button.js_on_click(args={'popup': popup}, code="popup.data.open = true")

help_button.preview(width=400, height=200)

Alternatively, we can also define an absolute position using the anchor_position argument, a tuple of the (vertical, horizontal) position:

popup = Popup("### Absolute position popup", open=True, anchor_position=(60, 120))

popup.preview(width=500, height=200)

Anchor & Transform Origin#

The anchor_origin determines which part of the anchor element the popup aligns to and the transform_origin the point on the popup which will attach to the anchor’s origin:

popup = Popup(
    "### Bottom-left anchored popup",
    open=True,
    anchor_origin={"horizontal": "left", "vertical": "bottom"},
    transform_origin={"horizontal": "right", "vertical": "center"}
)

anchor_btn = IconButton(icon="info", attached=[popup], styles={"margin-left": "auto"})

anchor_btn.js_on_click(args={'popup': popup}, code="popup.data.open = true")

anchor_btn.preview(width=400, height=200)

Non-modal dialog#

By default a Popup is modal: a backdrop covers the page and the focus is held inside the popup until it closes. Set modal=False for a popup that opens from a button and leaves the rest of the page usable, such as an info or filter panel:

  • The popup is exposed as a dialog with aria-modal="false", named by label or, without one, by its trigger.

  • The trigger, the button in the same layout that opened it, gets aria-haspopup="dialog" and an aria-expanded that follows open.

  • The popup is anchored to its trigger and the focus moves to its first focusable element when it opens. Escape closes it and returns the focus to the trigger.

  • Tab from the trigger moves into the popup, Shift+Tab from its start goes back to the trigger and Tab past its end closes it and returns to the trigger.

  • A click outside it (when close_on_click is set) or moving the focus elsewhere on the page closes it.

filters = Button(label="Filters", variant="outlined")
popup = Popup(
    "Only show rows updated this week.",
    Button(label="Apply"),
    modal=False,
    label="Filter options",
    anchor_origin={"horizontal": "left", "vertical": "bottom"},
    transform_origin={"horizontal": "left", "vertical": "top"},
)
filters.on_click(lambda event: popup.param.update(open=not popup.open))

# The popup anchors to its parent, so it sits next to the button.
Row(filters, popup).preview(height=200)

References#

Material UI Popover:

  • Material UI Popover Reference - Complete documentation for the underlying Material UI component

  • Material UI Popover API - Detailed API reference and configuration options


Download this notebook from GitHub (right-click to download).

previous

Paper

next

Tabs

On this page
  • Parameters
    • Core
    • Positioning
    • Styling
  • Basic Usage
  • Positioning
  • Anchor & Transform Origin
  • Non-modal dialog
  • References

© Copyright 2024-2026 Holoviz contributors.

Created using Sphinx 9.1.1.

Built with the PyData Sphinx Theme 0.16.1.