Button allows to trigger an action.


primaryboolfalseThe button with a theme color background. Usually, there is only one primary button on a form.
compoundboolfalseRender compound button with primary and secondaryText on a second line.
actionboolfalseRender button as a link without a border.
toolbarboolfalseRender toolbar-like button.
splitboolfalseIf set to true, and if menu items are provided, the button will render as a SplitButton.
textstringThe text displayed on a button.
secondaryTextstringDescription of the action this button takes. Only used for compound buttons.
urlstringIf provided, the button will be rendered as a link.
newWindowboolfalseWhether to open link in a new browser window.
titlestringPopup hint for the button.
iconstringIcon shown in the button.
iconColorstringIcon color.
datastringAdditional data attached to the control. The value is passed in click event data.


clickFires when a user clicks the button.

Child controls#

Item control#

Represents a menu item within a context menu button.


textstringText of the menu item. If a standard hyphen (-) is passed in, then the item will be rendered as a divider. If a dash must appear as text, use an emdash (โ€”), figuredash (โ€’), or minus symbol (โˆ’) instead.
secondaryTextstringSeconday description for the menu item to display.
urlstringURL to navigate to for this menu item.
newWindowboolfalseWhether to open link in a new browser window.
iconstringAn optional icon to display next to the item.
iconColorstringIcon color.
iconOnlyboolfalseShow only an icon for this item, not text. Does not apply if item is in the overflow.
splitboolfalseWhether or not this menu item is a SplitButton.
dividerboolfalseDisplay menu item as a divider.


clickFires when menu item is invoked.

Child controls#

Item control can contain other item controls to add nested menu items.


Adding a button with event handler:

btn_next = page.add(Button(text="Next", onclick=lambda e: print("Clicked!")))

or without lambda:

btn_next = Button(text="Next", onclick=next_onclick)
def next_onclick(e):
time.sleep(2) # simulate doing something