Skip to content

shiny.express.modal() should be a context manager #1810

@schloerke

Description

@schloerke

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
Image

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():

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions