Reference Manual: (offline | online) Quickstart: (offline | online)

# ui.button

Function: ui.button( | clicked=None, **properties)

This creates a button that can be clicked by the user. When this button is clicked or otherwise selected, the function supplied as the clicked argument is called. If it returns a value, that value is returned from ui.interact .

Buttons created with this function contain another widget, specifically the next widget to be added. As a convenience, one can use ui.textbutton to create a button with a text label.

clicked - A function that is called with no arguments when this button is clicked.

hovered - A function that is called with no arguments when this button is focused. If it returns a non-None value, then that value is returned from ui.interact .

unhovered - A function that is called with no arguments when the button loses focus.

role - The role this button undertakes. This can be the empty string, or "selected_".

## Example

    python:
        def button(text, selected, returns, **properties):
            style='selected_button'
            style_text='selected_button_text'

            if selected:
                role='selected_'
            else:
                 role=''

            ui.button(clicked=ui.returns(returns),
                      style='button', role=role, **properties)
            ui.text(text, style='button_text')

Reference Manual: (offline | online) Quickstart: (offline | online)