Hello All,
I am used to add bs_modal with a small information icon to explain properly the form of the input to the user. However, when creating an input using uiOutput and renderUI, I cannot make it work.
Does anyone have a working solution for this?
You can fin below a simple Reprex. The first numericInput has the desired bs_modal. I am trying to have the same for the second input (uiOutput).
In the example below, I did not add the code that I thought would make the bs_modal appear as the uiOutput did not show anymore when I tried.
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyBS)
library(bsplus)
library(shinyMatrix)
################ HEADER ################
header <- dashboardHeaderPlus(title = 'Example', titleWidth=300)
################ SIDEBAR ################
sidebar <- dashboardSidebar(
collapsed = TRUE,
disable = TRUE
)
################ BODY ################
body <- dashboardBody(
fluidPage(
tags$style(type="text/css",
".shiny-output-error {visibility: hidden; }",
".shiny-output-error:before {visibility: hidden; }"),
fluidRow(
column(width=4,
tags$head(
tags$style(type="text/css", ".inline label{ display: table-cell; text-align: left; vertical-align: middle; }
.inline .form-group{display: table-row;}")),
bs_modal(id = "Test", title = "Test", body = "This is a test!"),
bs_modal(id = "Options", title = "Options", body = "This is some options!"),
numericInput(inputId="test", label="Test : ", value=100, min=1, max=1000, step=1) %>%
shinyInput_label_embed(shiny_iconlink() %>% bs_attach_modal(id_modal = 'Test')),
uiOutput("options")
))
)
)
################ UI ################
ui <- dashboardPagePlus(
header,
sidebar,
sidebar_fullCollapse = TRUE,
body
)
################ SERVER ################
server <- function(input, output,session) {
output$options <- renderUI({
bs_modal(id = "Options", title = "Options", body = "Speak about options!")
options_mat <- matrix(c(100,120,0.2,0.17), 2, 2, dimnames = list(as.character(1:2), c("Test1","Test2")))
result <- matrixInput(inputId="options_matrix",label="Options' information : ",value = options_mat,rows = list(names = TRUE),cols = list(names = TRUE), class = "numeric")
result
})
}
################ SHINY APP ################
shinyApp(ui = ui, server = server)