Closed yogat3ch closed 1 week ago
For anyone landing here looking to do this, here's a hack with shinyjs
:
library(shiny)
library(shinyjs)
ui <- fluidPage(
shinyjs::useShinyjs(),
shinyWidgets::noUiSliderInput(
"slider",
label = tags$span("Some HTML"),
min = 0,
max = 100,
value = 55,
step = 1,
inline = TRUE
),
actionButton(
"update",
"Update the label"
),
actionButton(
"hack",
"shinyjs the label"
)
)
server <- function(input, output, session) {
observeEvent(input$update, {
shinyWidgets::updateNoUiSliderInput(
inputId = "slider",
label = htmltools::doRenderTags(tags$p("Some mo HTML"))
)
})
observeEvent(input$hack, {
shinyjs::html("slider-label", htmltools::doRenderTags(tags$h3("Hack that label")), asis = TRUE)
})
}
shinyApp(ui, server)
Hi shinyWidgets devs, It would be awesome if the
update
methods allowed HTML for thelabel
arg similar to the UI component call. This currently errors if ashiny.tag
is passed tolabel
on theupdate
method. Wrapping the tag withhtmltools::doRenderTags
, theupdate
method escapes the HTML and shows it as is (shown in this example):