Because a modal is similar to a card, I thought I'd be able to write:
from shiny.express import input, render, ui
with ui.modal():
ui.input_slider("n", "N", 0, 100, 20)
@render.code
def txt():
return f"n*2 is {input.n() * 2}"
Live app link
Current output

This occurs because shiny.express.modal is currently a re-export of shiny.ui.modal. I believe it should be an express context manager, similar to with shiny.express.h1():