PopupMenuButton
An icon button which displays a menu when clicked.
ft.PopupMenuButton(
items=[
ft.PopupMenuItem(content="Sm"),
ft.PopupMenuItem(content="Med"),
ft.PopupMenuItem(content="Lg"),
],
menu_position=ft.PopupMenuPosition.UNDER,
)

Inherits: LayoutControl
Properties
bgcolor- The menu's background color.clip_behavior- Thecontentwill be clipped (or not) according to this option.content- AControlthat will be displayed instead of "more" icon.elevation- The menu's elevation when opened.enable_feedback- Whether detected gestures should provide acoustic and/or haptic feedback.icon- If provided, an icon to draw on the button.icon_color- Theicon's color.icon_size- Theicon's size.items- A collection ofPopupMenuItemcontrols to display in a dropdown menu.menu_padding- TBDmenu_position- Defines position of the popup menu relative to the button.padding- TBDpopup_animation_style- TBDshadow_color- The color used to paint the shadow below the menu.shape- The menu's shape.size_constraints- TBDsplash_radius- The splash radius.style- TBD
Events
Examples
Basic Example
import flet as ft
def main(page: ft.Page):
def handle_check_item_click(e: ft.Event[ft.PopupMenuItem]):
e.control.checked = not e.control.checked
page.add(
ft.SafeArea(
content=ft.PopupMenuButton(
key="popup",
items=[
ft.PopupMenuItem(content="Item 1"),
ft.PopupMenuItem(icon=ft.Icons.POWER_INPUT, content="Check power"),
ft.PopupMenuItem(
content=ft.Row(
controls=[
ft.Icon(ft.Icons.HOURGLASS_TOP_OUTLINED),
ft.Text("Item with a custom content"),
]
),
on_click=lambda _: print("Button with custom content clicked!"),
),
ft.PopupMenuItem(), # divider
ft.PopupMenuItem(
content="Checked item",
checked=False,
on_click=handle_check_item_click,
),
],
)
)
)
if __name__ == "__main__":
ft.run(main)

Properties
bgcolorclass-attributeinstance-attribute
bgcolor: Optional[ColorValue] = NoneThe menu's background color.
clip_behaviorclass-attributeinstance-attribute
clip_behavior: ClipBehavior = ClipBehavior.NONEThe content will be clipped (or not) according to this option.
contentclass-attributeinstance-attribute
content: Optional[StrOrControl] = NoneA Control that will be displayed instead of "more" icon.
elevationclass-attributeinstance-attribute
elevation: Optional[Number] = NoneThe menu's elevation when opened.
Defaults to 8.
enable_feedbackclass-attributeinstance-attribute
enable_feedback: Optional[bool] = NoneWhether detected gestures should provide acoustic and/or haptic feedback.
On Android, for example, setting this to True produce a click sound and a
long-press will produce a short vibration.
Defaults to True.
iconclass-attributeinstance-attribute
icon: Optional[IconDataOrControl] = NoneIf provided, an icon to draw on the button.
icon_colorclass-attributeinstance-attribute
icon_color: Optional[ColorValue] = NoneThe icon's color.
itemsclass-attributeinstance-attribute
items: list[PopupMenuItem] = field(default_factory=list)A collection of PopupMenuItem controls to display in a dropdown menu.
menu_positionclass-attributeinstance-attribute
menu_position: Optional[PopupMenuPosition] = NoneDefines position of the popup menu relative to the button.
Defaults to PopupMenuPosition.OVER.
popup_animation_styleclass-attributeinstance-attribute
popup_animation_style: Optional[AnimationStyle] = NoneTBD
shadow_colorclass-attributeinstance-attribute
shadow_color: Optional[ColorValue] = NoneThe color used to paint the shadow below the menu.
shapeclass-attributeinstance-attribute
shape: Optional[OutlinedBorder] = NoneThe menu's shape.
Defaults to CircleBorder(radius=10.0).
size_constraintsclass-attributeinstance-attribute
size_constraints: Optional[BoxConstraints] = NoneTBD
Events
on_cancelclass-attributeinstance-attribute
on_cancel: Optional[ControlEventHandler[PopupMenuButton]] = NoneCalled when the user dismisses/cancels the popup menu without selecting an item.
on_openclass-attributeinstance-attribute
on_open: Optional[ControlEventHandler[PopupMenuButton]] = NoneCalled when the popup menu is shown.
on_selectclass-attributeinstance-attribute
on_select: Optional[ControlEventHandler[PopupMenuButton]] = NoneTBD
A popup menu item.
Inherits: Control
Properties
checked- Whether this menu item is checked.content- AControlrepresenting custom content of this menu item.height- The minimum height of this menu item.icon- An icon to draw before the text label of this menu item.label_text_style- The text style of the label of this menu item.mouse_cursor- The cursor to be displayed when a mouse pointer enters or is hovering over this item.padding- The padding of this menu item.
Events
on_click- Called when a user clicks on this menu item.
Properties
checkedclass-attributeinstance-attribute
checked: Optional[bool] = NoneWhether this menu item is checked.
If set to True, a checkmark will be shown on the left of the
content.
contentclass-attributeinstance-attribute
content: Optional[StrOrControl] = NoneA Control representing custom content of this menu item.
iconclass-attributeinstance-attribute
icon: Optional[IconDataOrControl] = NoneAn icon to draw before the text label of this menu item.
label_text_styleclass-attributeinstance-attribute
label_text_style: Optional[TextStyle] = NoneThe text style of the label of this menu item.
mouse_cursorclass-attributeinstance-attribute
mouse_cursor: Optional[MouseCursor] = NoneThe cursor to be displayed when a mouse pointer enters or is hovering over this item.
paddingclass-attributeinstance-attribute
padding: Optional[PaddingValue] = NoneThe padding of this menu item.
Defaults to Padding.symmetric(horizontal=12).
Events
on_clickclass-attributeinstance-attribute
on_click: Optional[ControlEventHandler[PopupMenuItem]] = NoneCalled when a user clicks on this menu item.