Action Link
#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [viewer]
#| viewerHeight: 200
## file: app.py
from shiny import App, reactive, render, ui
app_ui = ui.page_fluid(
    ui.row(
        ui.column(6, ui.input_action_link("action_link", "Increase Number")),
        ui.column(6, ui.output_text("counter").add_class("display-5 mb-0")),
        {"class": "vh-100 justify-content-center align-items-center px-5"},
    ).add_class("text-center")
)
def server(input, output, session):
    count = reactive.value(0)
    @reactive.effect
    @reactive.event(input.action_link)
    def _():
        count.set(count() + 1)
    @render.text()
    def counter():
        return f"{count()}"
app = App(app_ui, server)from shiny import App, reactive, render, ui
app_ui = ui.page_fluid(
    ui.input_action_link("action_link", "Increase Number"),  
    ui.output_text("counter"),
)
def server(input, output, session):
    count = reactive.value(0)
    @reactive.effect
    @reactive.event(input.action_link)  
    def _():
        count.set(count() + 1)
    @render.text()
    def counter():
        return f"{count()}"
app = App(app_ui, server)No matching items
Relevant Functions
- 
    
ui.input_action_link
ui.input_action_link(id, label, *, icon=None, **kwargs) - 
    
reactive.event
reactive.event(*args, ignore_none=True, ignore_init=False) 
No matching items
Details
An action link appears as a link in your app and has a value that increments each time the user presses the link.
Follow these steps to add an action link to your app:
- Add 
ui.input_action_link()to the UI of your app to create an action link. Where you call this function will determine where the link appears within the app’s layout. - Specify the 
idandlabelparameters ofui.input_action_link()to define the action link’s identifier and label. 
The value of an input component is accessible as a reactive value within the server() function. To access the value of an action link:
- Use 
input.<action_link_id()>(e.g.,input.action_link()) to access the value of the action link. The server value of an action link is an integer representing the number of clicks. 
See also: Action Button
Variation Showcase
A live kitchen sink of all possible parameters for the Action Link in Shiny Core and Shiny Express.
![]()
No matching items