Search code examples
rshinyshinydashboardshinyappsshiny-reactivity

how to change the text by change the slides in shiny


I want to change the name of the photo in front of the photo by changing each photo from the slide. But using the following codes, the input id is not displayed at all. The codes are as follow

library(shinydashboardPlus)

ui<-    dashboardPagePlus(title="Sample",
    dashboardHeaderPlus(title="Sample"),
          
dashboardSidebar(),
dashboardBody(

fluidRow(column(width=6, 
carousel(
id = "AA",
carouselItem(
caption = "Image1",
tags$img(src = "https://cdn.sstatic.net/Sites/stackoverflow/company/Img/logos/so/so-logo.svg?v=a010291124bf", height = 400, width = 400, align="center")
),
carouselItem(
caption = "Image2",
tags$img(src = "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", height = 400, width = 400, align="center")
))), 
column(width=6, uiOutput("Text"))
     )
)
)
server<- function(input, output, session) {
output$Text<-renderText({
Text<-input$AA
as.character(Text)
})
}
shinyApp(ui, server) ```

Solution

  • I do see them showing up. It's easier to see if you change the font size and color:

    library(shinydashboardPlus)
    library(shinydashboard)
    ui<-    dashboardPagePlus(title="Sample",
                              dashboardHeaderPlus(title="Sample"),
                              
                              dashboardSidebar(),
                              dashboardBody(
                                htmltools::tags$style(
                                  ".carousel-caption{
                                    font-size: 48px; 
                                    color: black;
                                  }"
                                ),
                                fluidRow(column(width=6, 
                                                carousel(
                                                  id = "AA",
                                                  carouselItem(
                                                    caption = "Image1",
                                                    tags$img(src = "https://cdn.sstatic.net/Sites/stackoverflow/company/Img/logos/so/so-logo.svg?v=a010291124bf", height = 400, width = 400, align="center")
                                                  ),
                                                  carouselItem(
                                                    caption = "Image2",
                                                    tags$img(src = "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", height = 400, width = 400, align="center")
                                                  ))), 
                                         column(width=6, uiOutput("Text"))
                                )
                              )
    )
    server<- function(input, output, session) {
      output$Text<-renderText({
        Text<-input$AA
        as.character(Text)
      })
    }
    shinyApp(ui, server)
    

    enter image description here enter image description here