0

I would like to build a shiny module whose UI part is a card from bslib. Like

my_mod_ui <- function(id) {
    ns <- shiny::NS(id)
    bslib::card(
        full_screen = TRUE, 
        bslib::card_header("My Title"), 
        bslib::layout_sidebar(
            sidebar = bslib::sidebar(
                open=TRUE,
                "Sidebar"
            ), 
            "Main contents"
        )
    )
}

Now the question I have is: where does the id argument go? There seems no named parameter in bslib::card() for this.

The background is that I want two cards with the same (but customizable) structure side-by-side in my dashboard. I think that a module would be the best way to do this.

Karsten W.
  • 17,826
  • 11
  • 69
  • 103

1 Answers1

1

From the help documents of bslib::card

... Unnamed arguments can be any valid child of an htmltools tag (which includes card items such as card_body(). Named arguments become HTML attributes on returned UI element.

Which means just pass an id argument

bslib::card(
  id = "myId",
  ...other arguments...
)
Marcus
  • 3,478
  • 1
  • 7
  • 16