Skip to main content
Ctrl+K
Panel 1.10.0b1.post1.dev31+g05db2c352 has just been released! Check out the release notes and support Panel by giving it a 🌟 on Github.
Panel v1.10.0b1 - Home Panel v1.10.0b1 - Home
  • Getting Started
  • Tutorials
  • Explanation
  • Component Gallery
  • How-to
    • App Gallery
    • API Reference
    • Community
    • Upgrade Guide
    • FAQ
    • About
    • Developer Guide
  • GitHub
  • Twitter
  • Discourse
  • Discord
  • Getting Started
  • Tutorials
  • Explanation
  • Component Gallery
  • How-to
  • App Gallery
  • API Reference
  • Community
  • Upgrade Guide
  • FAQ
  • About
  • Developer Guide
  • GitHub
  • Twitter
  • Discourse
  • Discord

FOR USERS

  • Getting Started
    • Installation
    • Build an App
    • Core Concepts
  • Tutorials
    • Basic Tutorials
      • Build Hello World App
      • Develop in a Notebook
      • Develop in an Editor
      • Display Content with pn.panel
      • Display Content with Panes
      • Display Performance with Indicators
      • Layout Content
      • Control the Size
      • Aligning Content
      • Accept Inputs with Widgets
      • React to User Input
      • Reactive Expressions
      • Utilize Templates
      • Apply a Design
      • Enhance the Style
      • Optimize Performance with Caching
      • Display Activity
      • Update Progressively
      • Build a Dashboard
      • Deploy a Dashboard
      • Build a Report
      • Build Animation
      • Build an Image Classifier
      • Build a Monitoring Dashboard
      • Build Crossfiltering Dashboard
      • Build Streaming Dashboard
      • Build a Chat Bot
      • Build a Todo App
    • Intermediate Tutorials
      • Reactive Parameters
      • Reusable Components
      • Interactivity
      • Structure with a DataStore
      • Develop in an Editor
      • Serve Apps
      • Advanced Layouts
      • Create a Form with HoloViz Panel
      • Build a Todo App
      • Testing the Todo App
      • Build a Server Side Video Camera Application
    • Expert Tutorials
      • Creating a MarioButton with AnyWidgetComponent
      • Creating a MarioButton with JSComponent
  • Explanation
    • Develop Seamlessly Across Environments
    • APIs
      • API context
        • Param in Panel
        • Reactivity in Panel
        • Classes vs functions in Panel: understanding the tradeoff
        • Reactive API
        • Declarative API
        • Callbacks
    • Components
      • Components overview
      • Custom components
    • Dependencies
      • Panel and Param
      • Panel and Bokeh
    • Technology comparisons
      • Panel vs Dash
      • Panel vs ipywidgets
      • Panel vs Voila
      • Panel vs Streamlit
      • Panel vs JavaScript
      • Panel vs Bokeh
  • Component Gallery
    • Classic Component Reference
      • Panes
        • AVIF
        • Alert
        • Audio
        • Bokeh
        • DataFrame
        • DeckGL
        • ECharts
        • Folium
        • GIF
        • HTML
        • HoloViews
        • IPyWidget
        • Image
        • JPG
        • JSON
        • LaTeX
        • Markdown
        • Matplotlib
        • PDF
        • PNG
        • Param
        • Perspective
        • Placeholder
        • Plotly
        • ReactiveExpr
        • Reacton
        • SVG
        • Str
        • Streamz
        • Textual
        • VTK
        • VTKJS
        • VTKVolume
        • Vega
        • Video
        • Vizzu
        • WebP
      • Widgets
        • ArrayInput
        • AutocompleteInput
        • Button
        • ButtonIcon
        • CheckBoxGroup
        • CheckButtonGroup
        • Checkbox
        • CodeEditor
        • ColorMap
        • ColorPicker
        • CrossSelector
        • DataFrame
        • DatePicker
        • DateRangePicker
        • DateRangeSlider
        • DateSlider
        • DatetimeInput
        • DatetimePicker
        • DatetimeRangeInput
        • DatetimeRangePicker
        • DatetimeRangeSlider
        • DatetimeSlider
        • Debugger
        • DiscretePlayer
        • DiscreteSlider
        • EditableFloatSlider
        • EditableIntSlider
        • EditableRangeSlider
        • FileDownload
        • FileDropper
        • FileInput
        • FileSelector
        • FloatInput
        • FloatSlider
        • IntInput
        • IntRangeSlider
        • IntSlider
        • JSONEditor
        • LiteralInput
        • MenuButton
        • MultiChoice
        • MultiSelect
        • NestedSelect
        • PasswordInput
        • Player
        • RadioBoxGroup
        • RadioButtonGroup
        • RangeSlider
        • Select
        • SpeechToText
        • StaticText
        • Switch
        • Tabulator
        • Terminal
        • TextAreaInput
        • TextEditor
        • TextInput
        • TextToSpeech
        • TimePicker
        • Toggle
        • ToggleGroup
        • ToggleIcon
        • VideoStream
      • Layouts
        • Accordion
        • Card
        • Column
        • Divider
        • Feed
        • FlexBox
        • FloatPanel
        • GridBox
        • GridSpec
        • GridStack
        • Modal
        • Row
        • Spacer
        • Swipe
        • Tabs
        • WidgetBox
      • Chat
        • ChatAreaInput
        • ChatFeed
        • ChatInterface
        • ChatMessage
        • ChatStep
        • PanelCallbackHandler
      • Global
        • Notifications
      • Indicators
        • BooleanStatus
        • Dial
        • Gauge
        • LinearGauge
        • LoadingSpinner
        • Number
        • Progress
        • TooltipIcon
        • Tqdm
        • Trend
      • Templates
        • Bootstrap
        • EditableTemplate
        • FastGridTemplate
        • FastListTemplate
        • GoldenLayout
        • Material
        • React
        • Slides
        • Vanilla
      • Custom Components
        • AnyWidgetComponent
        • JSComponent
        • PyComponent
        • ReactComponent
        • Viewer
    • Widgets
      • ArrayInput
      • AutocompleteInput
      • Avatar
      • BooleanStatus
      • Breadcrumbs
      • Button
      • ButtonIcon
      • CheckBoxGroup
      • CheckButtonGroup
      • Checkbox
      • Chip
      • CircularProgress
      • CodeEditor
      • ColorMap
      • ColorPicker
      • CrossSelector
      • DatePicker
      • DateRangePicker
      • DateRangeSlider
      • DateSlider
      • DatetimeInput
      • DatetimePicker
      • DatetimeRangeInput
      • DatetimeRangePicker
      • DatetimeRangeSlider
      • DatetimeSlider
      • Debugger
      • Dial
      • DictInput
      • DiscretePlayer
      • DiscreteSlider
      • EditableFloatSlider
      • EditableIntRangeSlider
      • EditableIntSlider
      • EditableRangeSlider
      • Fab
      • FileDownload
      • FileDropper
      • FileInput
      • FileSelector
      • FloatInput
      • FloatSlider
      • Gauge
      • IconButton
      • IntInput
      • IntRangeSlider
      • IntSlider
      • JSONEditor
      • LinearGauge
      • LinearProgress
      • ListInput
      • LiteralInput
      • LoadingSpinner
      • MenuBar
      • MenuButton
      • MenuList
      • MenuToggle
      • MultiChoice
      • MultiPill
      • MultiSelect
      • NestedBreadcrumbs
      • NestedSelect
      • Number
      • NumberInput
      • Pagination
      • PasswordInput
      • Pill
      • Player
      • Progress
      • RadioBoxGroup
      • RadioButtonGroup
      • RangeSlider
      • Rating
      • Select
      • SpeechToText
      • SpeedDial
      • SplitButton
      • StaticText
      • StepperMenu
      • Switch
      • TabMenu
      • Tabulator
      • Terminal
      • TextAreaInput
      • TextEditor
      • TextInput
      • TextToSpeech
      • TimePicker
      • Toggle
      • ToggleGroup
      • ToggleIcon
      • TooltipIcon
      • Tqdm
      • Tree
      • Trend
      • TupleInput
      • VideoStream
    • Layouts
      • Accordion
      • Alert
      • Backdrop
      • Card
      • Column
      • Container
      • Details
      • Dialog
      • Divider
      • Drawer
      • Feed
      • FlexBox
      • FloatPanel
      • Grid
      • GridBox
      • GridSpec
      • GridStack
      • HSpacer
      • Modal
      • Paper
      • Popup
      • Row
      • Spacer
      • Swipe
      • Tabs
      • VSpacer
      • WidgetBox
    • Panes
      • AVIF
      • Audio
      • Bokeh
      • DataFrame
      • DeckGL
      • ECharts
      • GIF
      • HTML
      • HoloViews
      • ICO
      • IPyLeaflet
      • IPyWidget
      • Image
      • Interactive
      • JPG
      • JSON
      • LaTeX
      • Markdown
      • Matplotlib
      • PDF
      • PNG
      • ParamFunction
      • ParamMethod
      • ParamRef
      • Perspective
      • Placeholder
      • Plotly
      • RGGPlot
      • ReactiveExpr
      • Reacton
      • SVG
      • Str
      • Streamz
      • Textual
      • Typography
      • VTKVolume
      • Vega
      • Video
      • Vizzu
      • YT
    • Chat
      • ChatAreaInput
      • ChatFeed
      • ChatInterface
      • ChatMessage
      • ChatReactionIcons
      • ChatStep
    • Indicators
      • BooleanStatus
      • CircularProgress
      • Dial
      • Gauge
      • LinearGauge
      • LinearProgress
      • LoadingSpinner
      • Number
      • Progress
      • String
      • TooltipIcon
      • Tqdm
      • Trend
    • Wrappers
      • Badge
      • Clickable
      • Skeleton
      • Tooltip
      • Transition
      • Wrapper
    • Templates
      • AppBar
      • BreakpointSwitcher
      • Page
      • ThemeToggle
  • How-to
    • Prepare to develop
      • Develop in a notebook
        • Display Output in Notebooks
        • Preview Apps in JupyterLab
        • Publish a Notebook as a Dashboard Using the Layout Builder
        • Develop in other notebook environments
      • Develop in an editor
        • Configure VS Code
        • Configure PyCharm
        • Write apps in Markdown
      • Type check your code
    • Build apps
      • Construct individual components
        • Construct Panes
        • Access Pane Type
        • Access and Set Widget Values
        • Construct Widgets from Data
        • Add or Remove Components from Panels
      • Styling components
        • Apply a Design
        • Toggling themes
        • Apply CSS
        • Customize a Design
        • Customize Loading Icon
        • Control Visibility
        • Style Altair Plots
        • Style Echarts Plots
        • Style Matplotlib Plots
        • Style Plotly Plots
        • Style Vega Plots
      • Interactivity
        • Add interactivity to a function
        • Add interactivity with generators
        • Add reactivity to components
        • Make interactive data workflows
      • Arranging components
        • Customize Spacing
        • Align Components
        • Control Size
    • Using Panel with an AI assistant
    • Use specialized UIs and APIs
      • Build a sequential UI
        • Create a Pipeline
        • Create a Non-Linear Pipeline
        • Customize Pipeline Layout
        • Control Pipeline Flow
      • Build custom components
        • Combine Existing Components
        • Build a Widget in Python
        • Plot Viewer
        • How to Create Reactive Tables with Panel
        • Publish a Panel Extension
        • Compile and Bundle ESM Components
        • ESM component with callback
        • Create Panes using ESM Components
        • Create Custom Widgets using ESM Components
        • Create Custom Layouts using ESM Components
        • Rendering DataFrames using ESM components
        • Build a Custom Canvas Component
        • Build a Custom Leaflet Component
        • Wrapping Material UI components
        • Create Layouts With ReactiveHTML
        • Style your ReactiveHTML template
        • Create Panes with ReactiveHTML
        • Create Indicators With ReactiveHTML
        • ReactiveHTML component with callback
        • Widgets with ReactiveHTML
        • DataFrames and ReactiveHTML
        • Build a Custom Canvas Component
        • Build a Custom Leaflet Component
        • Wrap a Vue component
      • Explicitly link parameters (Callbacks API)
        • Create High-Level Python Links with .link
        • Create Low-Level Python Links Using .watch
        • Link Two Objects in Javascript
        • Link Plot Parameters in Javascript
        • Link Many Objects in Javascript
      • Generate UIs from declared parameters (Declarative API)
        • Generate Widgets from Parameters
        • Declare Custom Widgets
        • Declare parameter dependencies
        • Create nested UIs
    • Manage session tasks
      • Register Session Callbacks
        • Use Asynchronous Callbacks
        • Defer Bound Functions to Improve the User Experience
        • Defer Long Running Tasks to Improve the User Experience
        • Run Tasks at Session Start or End
        • Periodically Run Callbacks
        • Schedule Global Tasks
        • Modify Bokeh Models
        • Add notifications on connect and disconnect
      • Access Session State
        • Access and Manipulate the URL
        • Access HTTP Request State
        • Access Busyness state
    • Extending Panel
      • Create Custom Components
        • Combine Existing Components
        • Build a Widget in Python
        • Plot Viewer
        • How to Create Reactive Tables with Panel
        • Publish a Panel Extension
        • Compile and Bundle ESM Components
        • ESM component with callback
        • Create Panes using ESM Components
        • Create Custom Widgets using ESM Components
        • Create Custom Layouts using ESM Components
        • Rendering DataFrames using ESM components
        • Build a Custom Canvas Component
        • Build a Custom Leaflet Component
        • Wrapping Material UI components
        • Create Layouts With ReactiveHTML
        • Style your ReactiveHTML template
        • Create Panes with ReactiveHTML
        • Create Indicators With ReactiveHTML
        • ReactiveHTML component with callback
        • Widgets with ReactiveHTML
        • DataFrames and ReactiveHTML
        • Build a Custom Canvas Component
        • Build a Custom Leaflet Component
        • Wrap a Vue component
    • Test and debug
      • Enable profiling and debugging
        • Enable the admin panel
        • Profile your Application
        • View application logs
      • Set up testing for an application
        • Test functionality and performance
        • Test UI rendering
        • Test operating capacity
    • Prepare to share
      • Apply Templates
        • Set a Template
        • Arrange Components in a Template
        • Toggle Modal
        • Customize Template Theme
        • Build a Custom Template
      • Improve Performance
        • Reuse sessions
        • Enable Throttling
        • Batching Updates with hold
        • Control when resources load
      • Cache Data
        • Manually Cache
        • Automatically Cache
      • Improve Scalability
        • Load balancing
        • Launch multiple processes
        • Enable Automatic Threading
        • Set Up Manual Threading
        • Use Asynchronous Callbacks
        • Run synchronous functions asynchronously
        • Scaling with Dask
      • Best Practices
        • Developer Experience
        • User Experience
      • Add Authentication
        • Configuring Basic Authentication
        • Configuring OAuth
        • Configuring PAM Authentication
        • OAuth Providers
        • Authentication Templates
        • Accessing User information
        • Access Tokens
        • Authorization callbacks
        • Allowing Guest Users
        • Troubleshooting OAuth
    • Share your work
      • Configure the server
        • Launch a server on the command line
        • Launching a server dynamically
        • Serving multiple applications
        • Serving applications on wildcard routes
        • Connect to a remote server via SSH
        • Re-connecting to a Session
        • Configuring a reverse proxy
        • Serving static files
        • Add custom endpoints to the Panel Server
        • Configuring WebSocket Communication Settings
      • Distribute applications
        • How to Share Panel Scripts with uv
      • Integrate with other servers
        • Running Panel apps in FastAPI
        • Embedding a Panel Server in FastAPI
        • Integrating Panel with Flask
        • Running Panel apps inside Django
      • Deploy applications
        • Anaconda Notebooks
        • AWS: Amazon Web Services
        • Microsoft Azure
        • MyBinder
        • Google Cloud Platform (GCP)
        • Heroku
        • Hugging Face
        • Outerbounds
        • PyCafe Guide
        • PythonAnywhere
      • Export apps
        • Embedding state
        • Save App to File
        • Access the Bokeh Model
      • Run panel in WebAssembly
        • Using Panel in Pyodide & PyScript
        • Converting Panel applications
        • Embedding in Sphinx documentation
        • Setting up JupyterLite
      • Convert to desktop or mobile apps
        • Create Desktop Apps with pywebview
        • Create Cross-Platform Apps with Toga
    • Migrate to Panel
      • Migrate from Streamlit
        • Serve Apps
        • Display Objects with Panes
        • Layout Objects
        • Accepting User Inputs with Widgets
        • Organize and Style with Templates
        • Show Activity
        • Add Interactivity with pn.bind
        • Improve the performance with Caching
        • Session State
        • Create Chat Interfaces
        • Multi Page Apps
  • App Gallery
    • Altair Brushing
    • Deckgl Game Of Life
    • Gapminders
    • Glaciers
    • Hvplot Explorer
    • Iris Kmeans
    • Nyc Deckgl
    • Penguin Crossfilter
    • Penguin Kmeans
    • Portfolio Analyzer
    • Portfolio Optimizer
    • Streaming Videostream
    • Vtk Interactive
    • Vtk Slicer
    • Vtk Warp
    • Webllm
    • Windturbines
    • Xgboost Classifier
  • API Reference
    • Cheat Sheet
    • Config
    • State
    • panel.auth module
    • panel.chat package
      • panel.chat.feed module
      • panel.chat.icon module
      • panel.chat.input module
      • panel.chat.interface module
      • panel.chat.message module
      • panel.chat.step module
      • panel.chat.utils module
    • panel.command package
      • panel.command.bundle module
      • panel.command.compile module
      • panel.command.convert module
      • panel.command.migrate module
      • panel.command.oauth_secret module
      • panel.command.serve module
    • panel.compiler module
    • panel.config module
    • panel.custom module
    • panel.depends module
    • panel.io package
      • panel.io.django package
        • panel.io.django.management package
        • panel.io.django.apps module
      • panel.io.admin module
      • panel.io.application module
      • panel.io.asgi module
      • panel.io.auth module
      • panel.io.browser module
      • panel.io.cache module
      • panel.io.callbacks module
      • panel.io.compile module
      • panel.io.convert module
      • panel.io.datamodel module
      • panel.io.document module
      • panel.io.embed module
      • panel.io.fastapi module
      • panel.io.handlers module
      • panel.io.ipywidget module
      • panel.io.jupyter_executor module
      • panel.io.jupyter_server_extension module
      • panel.io.liveness module
      • panel.io.loading module
      • panel.io.location module
      • panel.io.logging module
      • panel.io.mime_render module
      • panel.io.model module
      • panel.io.notebook module
      • panel.io.notifications module
      • panel.io.profile module
      • panel.io.pyodide module
      • panel.io.reload module
      • panel.io.resource_spec module
      • panel.io.resources module
      • panel.io.rest module
      • panel.io.save module
      • panel.io.server module
      • panel.io.session module
      • panel.io.state module
      • panel.io.threads module
      • panel.io.watcher module
    • panel.layout package
      • panel.layout.accordion module
      • panel.layout.base module
      • panel.layout.card module
      • panel.layout.feed module
      • panel.layout.flex module
      • panel.layout.float module
      • panel.layout.grid module
      • panel.layout.gridstack module
      • panel.layout.modal module
      • panel.layout.spacer module
      • panel.layout.swipe module
      • panel.layout.tabs module
    • panel.links module
    • panel.models package
      • panel.models.ace module
      • panel.models.browser module
      • panel.models.chatarea_input module
      • panel.models.comm_manager module
      • panel.models.datetime_picker module
      • panel.models.datetime_slider module
      • panel.models.deckgl module
      • panel.models.echarts module
      • panel.models.enums module
      • panel.models.esm module
      • panel.models.feed module
      • panel.models.file_dropper module
      • panel.models.icon module
      • panel.models.ipywidget module
      • panel.models.jsoneditor module
      • panel.models.katex module
      • panel.models.layout module
      • panel.models.location module
      • panel.models.markup module
      • panel.models.mathjax module
      • panel.models.modal module
      • panel.models.perspective module
      • panel.models.plotly module
      • panel.models.quill module
      • panel.models.reactive_html module
      • panel.models.resource module
      • panel.models.speech_to_text module
      • panel.models.state module
      • panel.models.tabs module
      • panel.models.tabulator module
      • panel.models.terminal module
      • panel.models.text_to_speech module
      • panel.models.time_picker module
      • panel.models.trend module
      • panel.models.vega module
      • panel.models.vizzu module
      • panel.models.vtk module
      • panel.models.widgets module
    • panel.pane package
      • panel.pane.vtk package
        • panel.pane.vtk.enums module
        • panel.pane.vtk.synchronizable_deserializer module
        • panel.pane.vtk.synchronizable_serializer module
        • panel.pane.vtk.vtk module
      • panel.pane.alert module
      • panel.pane.base module
      • panel.pane.deckgl module
      • panel.pane.echarts module
      • panel.pane.equation module
      • panel.pane.holoviews module
      • panel.pane.image module
      • panel.pane.ipywidget module
      • panel.pane.markup module
      • panel.pane.media module
      • panel.pane.perspective module
      • panel.pane.placeholder module
      • panel.pane.plot module
      • panel.pane.plotly module
      • panel.pane.streamz module
      • panel.pane.textual module
      • panel.pane.vega module
      • panel.pane.vizzu module
    • panel.param module
    • panel.pipeline module
    • panel.reactive module
    • panel.template package
      • panel.template.bootstrap package
      • panel.template.editable package
      • panel.template.fast package
        • panel.template.fast.grid package
        • panel.template.fast.list package
        • panel.template.fast.base module
      • panel.template.golden package
      • panel.template.material package
      • panel.template.react package
      • panel.template.slides package
      • panel.template.vanilla package
      • panel.template.base module
    • panel.theme package
      • panel.theme.base module
      • panel.theme.bootstrap module
      • panel.theme.fast module
      • panel.theme.material module
      • panel.theme.native module
    • panel.util package
      • panel.util.checks module
      • panel.util.parameters module
      • panel.util.warnings module
    • panel.viewable module
    • panel.widgets package
      • panel.widgets.base module
      • panel.widgets.button module
      • panel.widgets.codeeditor module
      • panel.widgets.debugger module
      • panel.widgets.file_selector module
      • panel.widgets.icon module
      • panel.widgets.indicators module
      • panel.widgets.input module
      • panel.widgets.misc module
      • panel.widgets.player module
      • panel.widgets.select module
      • panel.widgets.slider module
      • panel.widgets.speech_to_text module
      • panel.widgets.tables module
      • panel.widgets.terminal module
      • panel.widgets.text_to_speech module
      • panel.widgets.texteditor module
      • panel.widgets.widget module
  • Community
  • Upgrade Guide
  • FAQ
  • About
    • Releases
    • People
    • Roadmap

FOR DEVELOPERS

  • Developer Guide
    • Extensions
    • WASM
    • Developing custom models
HoloViz.org
  • hvPlot
  • HoloViews
  • GeoViews
  • Datashader
  • Param
  • Lumen
  • Colorcet

  • Examples Gallery
  • Blog
  • Component Gallery
  • Widgets
  • MenuBar

MenuBar#

Material version available

pn.ui.MenuBar resolves to the Material Design implementation of this component, documented in the panel-material-ui reference. This page documents the classic pn.widgets.MenuBar.

import panel as pn
import panel.ui

pn.extension()

The MenuBar component provides a horizontal application menu bar, similar to those found in desktop applications (File, Edit, View, Help). It supports nested submenus, keyboard shortcut hints, icons, checkboxes, radio groups, item groups, and dividers.

Item Structure#

The top-level items list defines the menu triggers (buttons) in the bar. Each top-level item should have:

  • label (str, required): The button text.

  • icon (str, optional): Icon displayed before the label.

  • disabled (bool, optional): Whether the entire menu is disabled.

  • items (list[dict], required): The dropdown items for this menu.

Each dropdown item can be:

  • A regular item: {'label': 'Save', 'icon': 'save', 'hint': 'Ctrl+S'}

  • A divider: None or {'label': '---'}

  • A submenu: {'label': 'Share', 'icon': 'share', 'items': [...]}

  • A group header: {'label': 'Alignment', 'group': True, 'items': [...]}

  • A checkbox item: {'label': 'Show Toolbar', 'checkbox': True}

  • A radio item: {'label': 'Light', 'radio': 'light'}

Parameters#

Core#

  • active (tuple[int, ...]): Index path of the last clicked item.

  • items (list[dict]): Top-level menus with their dropdown items.

  • value (dict): The last clicked item.

Display#

  • color (str): Color of the menu bar buttons. One of 'default', 'primary', 'secondary', 'success', 'info', 'warning', 'error'.

  • size (str): Size of the menu buttons: 'small', 'medium', or 'large'.

  • variant (str): Visual style of the bar container: 'elevation' or 'outlined'.

Styling#

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

  • theme_config (dict): Theming API.


Basic Usage#

A simple menu bar with File, Edit, and Help menus:

menu_bar = pn.ui.MenuBar(items=[
    {'label': 'File', 'items': [
        {'label': 'New', 'icon': 'note_add', 'hint': 'Ctrl+N'},
        {'label': 'Open', 'icon': 'folder_open', 'hint': 'Ctrl+O'},
        {'label': 'Save', 'icon': 'save', 'hint': 'Ctrl+S'},
        {'label': 'Save As...', 'icon': 'save_as', 'hint': 'Ctrl+Shift+S'},
        None,
        {'label': 'Exit', 'icon': 'close'},
    ]},
    {'label': 'Edit', 'items': [
        {'label': 'Undo', 'icon': 'undo', 'hint': 'Ctrl+Z'},
        {'label': 'Redo', 'icon': 'redo', 'hint': 'Ctrl+Y'},
        None,
        {'label': 'Cut', 'icon': 'content_cut', 'hint': 'Ctrl+X'},
        {'label': 'Copy', 'icon': 'content_copy', 'hint': 'Ctrl+C'},
        {'label': 'Paste', 'icon': 'content_paste', 'hint': 'Ctrl+V'},
    ]},
    {'label': 'Help', 'items': [
        {'label': 'Documentation', 'icon': 'menu_book'},
        {'label': 'About', 'icon': 'info'},
    ]},
], margin=(0, 0, 200, 0))

menu_bar

Clicking an item updates both active (the index path) and value (the item dict):

menu_bar.active, menu_bar.value
(None, None)

Nested Submenus#

Items with an items key (and no group key) render as fly-out submenus:

pn.ui.MenuBar(items=[
    {'label': 'File', 'items': [
        {'label': 'New', 'icon': 'note_add'},
        {'label': 'Open Recent', 'icon': 'history', 'items': [
            {'label': 'project_v2.py'},
            {'label': 'analysis.ipynb'},
            {'label': 'dashboard.py'},
        ]},
        None,
        {'label': 'Share', 'icon': 'share', 'items': [
            {'label': 'Email Link', 'icon': 'email'},
            {'label': 'Copy Link', 'icon': 'link'},
            {'label': 'Export PDF', 'icon': 'picture_as_pdf'},
        ]},
        None,
        {'label': 'Close', 'icon': 'close', 'hint': 'Ctrl+W'},
    ]},
], margin=(0, 0, 200, 0))

Checkbox Items#

Items with a checkbox key render a checkbox. The value toggles when clicked and updates the items in-place:

view_menu = pn.ui.MenuBar(items=[
    {'label': 'View', 'items': [
        {'label': 'Show Toolbar', 'checkbox': True},
        {'label': 'Show Sidebar', 'checkbox': True},
        {'label': 'Show Status Bar', 'checkbox': False},
        None,
        {'label': 'Full Screen', 'icon': 'fullscreen', 'hint': 'F11'},
    ]},
], margin=(0, 0, 200, 0))

view_menu

After toggling checkboxes, the updated state is reflected on items:

view_menu.items[0]['items'][:3]
[{'label': 'Show Toolbar', 'checkbox': True}, {'label': 'Show Sidebar', 'checkbox': True}, {'label': 'Show Status Bar', 'checkbox': False}]

Radio Items#

Items with a radio key render as mutually exclusive radio options. All radio items at the same nesting level form a group. Set _radio_selected: True on the initially selected item:

pn.ui.MenuBar(items=[
    {'label': 'Theme', 'items': [
        {'label': 'Light', 'radio': 'light', '_radio_selected': True},
        {'label': 'Dark', 'radio': 'dark'},
        {'label': 'System', 'radio': 'system'},
    ]},
], margin=(0, 0, 200, 0))

Groups#

Items with group: True render their sub-items as a labeled section (with a subheader), rather than as a nested submenu. This is useful for organizing related options visually:

pn.ui.MenuBar(items=[
    {'label': 'Format', 'items': [
        {'label': 'Text', 'group': True, 'icon': 'text_fields', 'items': [
            {'label': 'Bold', 'icon': 'format_bold', 'hint': 'Ctrl+B'},
            {'label': 'Italic', 'icon': 'format_italic', 'hint': 'Ctrl+I'},
            {'label': 'Underline', 'icon': 'format_underlined', 'hint': 'Ctrl+U'},
        ]},
        {'label': 'Paragraph', 'group': True, 'icon': 'format_align_left', 'items': [
            {'label': 'Align Left', 'icon': 'format_align_left'},
            {'label': 'Align Center', 'icon': 'format_align_center'},
            {'label': 'Align Right', 'icon': 'format_align_right'},
        ]},
    ]},
], margin=(0, 0, 200, 0))

Callbacks#

Use on_click to register a callback that fires whenever a menu item is clicked:

callback_bar = pn.ui.MenuBar(items=[
    {'label': 'Actions', 'items': [
        {'label': 'Run', 'icon': 'play_arrow', 'hint': 'F5'},
        {'label': 'Debug', 'icon': 'bug_report', 'hint': 'F9'},
        {'label': 'Stop', 'icon': 'stop', 'hint': 'Shift+F5'},
    ]},
], margin=(0, 0, 200, 0))

log = pn.Column()

callback_bar.on_click(lambda item: log.append(f"Clicked: {item['label']}"))

pn.ui.Row(callback_bar, log)

Icons on Top-Level Menus#

Top-level menu triggers can also display icons:

pn.ui.MenuBar(items=[
    {'label': 'File', 'icon': 'description', 'items': [
        {'label': 'New', 'icon': 'note_add'},
        {'label': 'Open', 'icon': 'folder_open'},
    ]},
    {'label': 'Edit', 'icon': 'edit', 'items': [
        {'label': 'Undo', 'icon': 'undo'},
        {'label': 'Redo', 'icon': 'redo'},
    ]},
    {'label': 'View', 'icon': 'visibility', 'items': [
        {'label': 'Zoom In', 'icon': 'zoom_in'},
        {'label': 'Zoom Out', 'icon': 'zoom_out'},
    ]},
], margin=(0, 0, 200, 0))

Disabled Menus#

Individual top-level menus or specific items can be disabled:

pn.ui.MenuBar(items=[
    {'label': 'File', 'items': [
        {'label': 'New', 'icon': 'note_add'},
        {'label': 'Save', 'icon': 'save', 'disabled': True},
    ]},
    {'label': 'Edit', 'disabled': True, 'items': [
        {'label': 'Undo'},
    ]},
    {'label': 'Help', 'items': [
        {'label': 'About', 'icon': 'info'},
    ]},
], margin=(0, 0, 200, 0))

Color and Size#

The color parameter controls the button color, and size adjusts the button size:

sample_items = [
    {'label': 'File', 'items': [{'label': 'New'}, {'label': 'Open'}]},
    {'label': 'Edit', 'items': [{'label': 'Undo'}, {'label': 'Redo'}]},
]

pn.ui.Row(
    pn.ui.MenuBar(items=sample_items, color='primary'),
    pn.ui.MenuBar(items=sample_items, color='secondary'),
    pn.ui.MenuBar(items=sample_items, color='success'),
    margin=(0, 0, 200, 0)
)

Variant#

The variant parameter controls the container style, either 'elevation' (with a shadow) or 'outlined' (with a border):

pn.Row(
    pn.ui.MenuBar(items=sample_items, variant='elevation'),
    pn.ui.MenuBar(items=sample_items, variant='outlined'),
)

Complete Example#

A comprehensive menu bar combining multiple features:

pn.ui.MenuBar(items=[
    {'label': 'File', 'items': [
        {'label': 'New', 'icon': 'note_add', 'hint': 'Ctrl+N'},
        {'label': 'Open', 'icon': 'folder_open', 'hint': 'Ctrl+O'},
        {'label': 'Open Recent', 'icon': 'history', 'items': [
            {'label': 'project.py'},
            {'label': 'analysis.ipynb'},
            {'label': 'dashboard.py'},
        ]},
        None,
        {'label': 'Save', 'icon': 'save', 'hint': 'Ctrl+S'},
        {'label': 'Save As...', 'icon': 'save_as'},
        None,
        {'label': 'Exit', 'icon': 'close'},
    ]},
    {'label': 'Edit', 'items': [
        {'label': 'Undo', 'icon': 'undo', 'hint': 'Ctrl+Z'},
        {'label': 'Redo', 'icon': 'redo', 'hint': 'Ctrl+Y'},
        None,
        {'label': 'Cut', 'icon': 'content_cut', 'hint': 'Ctrl+X'},
        {'label': 'Copy', 'icon': 'content_copy', 'hint': 'Ctrl+C'},
        {'label': 'Paste', 'icon': 'content_paste', 'hint': 'Ctrl+V'},
        None,
        {'label': 'Find', 'icon': 'search', 'hint': 'Ctrl+F'},
        {'label': 'Replace', 'icon': 'find_replace', 'hint': 'Ctrl+H'},
    ]},
    {'label': 'View', 'items': [
        {'label': 'Show Toolbar', 'checkbox': True},
        {'label': 'Show Sidebar', 'checkbox': True},
        {'label': 'Show Minimap', 'checkbox': False},
        None,
        {'label': 'Theme', 'group': True, 'icon': 'palette', 'items': [
            {'label': 'Light', 'radio': 'light', '_radio_selected': True},
            {'label': 'Dark', 'radio': 'dark'},
            {'label': 'System', 'radio': 'system'},
        ]},
        {'label': 'Zoom In', 'icon': 'zoom_in', 'hint': 'Ctrl++'},
        {'label': 'Zoom Out', 'icon': 'zoom_out', 'hint': 'Ctrl+-'},
    ]},
    {'label': 'Help', 'items': [
        {'label': 'Documentation', 'icon': 'menu_book'},
        {'label': 'Release Notes', 'icon': 'new_releases'},
        None,
        {'label': 'Report Issue', 'icon': 'bug_report'},
        None,
        {'label': 'About', 'icon': 'info'},
    ]},
], margin=(0, 0, 300, 0))

API Reference#

Parameters#

The MenuBar exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:

pn.ui.MenuBar(items=[
    {'label': 'File', 'items': [
        {'label': 'New', 'icon': 'note_add'},
        {'label': 'Open', 'icon': 'folder_open'},
        {'label': 'Save', 'icon': 'save'},
    ]},
    {'label': 'Edit', 'items': [
        {'label': 'Undo', 'icon': 'undo'},
        {'label': 'Redo', 'icon': 'redo'},
    ]},
]).api(jslink=True)

References#

Panel Documentation:

  • How-to guides on interactivity - Learn how to add interactivity to your applications using widgets

  • Setting up callbacks and links - Connect parameters between components and create reactive interfaces

  • Declarative UIs with Param - Build parameter-driven applications

Material UI:

  • Material UI MenuBar - Complete documentation for the underlying Material UI component

  • Material UI Menu - Menu component reference

  • Material UI Menu API - Detailed API reference

previous

LoadingSpinner

next

MenuButton

Support us with a star on GitHub
launch jupyterlite
On this page
  • Item Structure
  • Parameters
    • Core
    • Display
    • Styling
  • Basic Usage
  • Nested Submenus
  • Checkbox Items
  • Radio Items
  • Groups
  • Callbacks
  • Icons on Top-Level Menus
  • Disabled Menus
  • Color and Size
  • Variant
  • Complete Example
    • API Reference
      • Parameters
    • References

© Copyright 2019-2026 Holoviz contributors.

Created using Sphinx 9.1.0.

Built with the PyData Sphinx Theme 0.16.1.