I have a selectInput
in my shiny app, and I want every input to this selectInput
to change the h1 title of my fluidRow
div. I am trying to use glue package but it’s not working.
This is my app:
library(shiny)
ui <- fluidPage(
fluidRow(
column(6,
selectInput('names',
label = "Selection",
choices= names(mtcars))),
column(6,
tags$html(h1(glue::glue("title {input$names}"))))
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
What is the best practice to change html elements when shiny inputs are changed?
CodePudding user response:
You could change to htmlOutput
in the UI, and then on the server side use renderUI.
UI:
htmlOutput("title")
Server:
output$title <- renderUI({
HTML(<h1>paste0("title: ", input$names))
})