ui.input_action_button
Creates an action button whose value is initially zero, and increments by one each time it is pressed.
Parameters
- id : str
- 
An input id. 
- label : TagChild
- 
An input label. 
- icon : TagChild = None
- 
An icon to appear inline with the button/link. 
- width : Optional[str] = None
- 
The CSS width, e.g. ‘400px’, or ‘100%’ 
- disabled : bool = False
- 
If True, the button will not be clickable. Use update_action_button to dynamically enable/disable the button.
- ****kwargs** : TagAttrValue = {}
- 
Attributes to be applied to the button. 
Returns
- : Tag
- 
A UI element 
Notes
Server value
An integer representing the number of clicks.
See Also
Examples
#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
import matplotlib.pyplot as plt
import numpy as np
from shiny import App, Inputs, Outputs, Session, reactive, render, ui
app_ui = ui.page_fluid(
    ui.input_slider("n", "Number of observations", min=0, max=1000, value=500),
    ui.input_action_button("go", "Go!", class_="btn-success"),
    ui.output_plot("plot"),
)
def server(input: Inputs, output: Outputs, session: Session):
    @render.plot(alt="A histogram")
    # Use reactive.event() to invalidate the plot only when the button is pressed
    # (not when the slider is changed)
    @reactive.event(input.go, ignore_none=False)
    def plot():
        np.random.seed(19680801)
        x = 100 + 15 * np.random.randn(input.n())
        fig, ax = plt.subplots()
        ax.hist(x, bins=30, density=True)
        return fig
app = App(app_ui, server)
#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import App, Inputs, reactive, render, ui
app_ui = ui.page_fluid(
    ui.input_text("name", "Your Name"),
    ui.input_action_button("greet", "Say Hello", disabled=True),
    ui.output_ui("hello"),
)
def server(input: Inputs):
    @reactive.effect
    @reactive.event(input.name)
    def set_button_state():
        if input.name():
            ui.update_action_button("greet", disabled=False)
        else:
            ui.update_action_button("greet", disabled=True)
    @render.ui
    @reactive.event(input.greet)
    def hello():
        return ui.p(f"Hello, {input.name()}!", class_="fs-1 text-primary mt-3")
app = App(app_ui, server)