express.module
express.module(fn)
Create a Shiny module using Shiny Express syntax
This function is used to create a Shiny module, where the code inside the function uses Shiny Express syntax. This is in contrast to the pair of functions :func:~shiny.module.ui()
and :func:~shiny.module.server()
, which are used to create Shiny modules with Core syntax.
Parameters
See Also
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import reactive
from shiny.express import module, render, ui
@module
def counter(input, output, session, starting_value: int = 0):
count = reactive.value(starting_value)
ui.input_action_button("btn", "Increment")
with ui.div():
@render.express
def current_count():
count()
@reactive.effect
@reactive.event(input.btn)
def increment():
count.set(count() + 1)
counter("one")
ui.hr()
counter("two")