Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an infomation button in shiny dashboard

I would like to show a information button in my shiny app, where user can click and an text (information) box pop out with some text there. This is for users to click on the button to get some general description about some part of my shiny app.

For some reason, I could not find it in shiny or shinydashboard for that purpose. Does anyone know how I can make the button? Thanks.

like image 467
zesla Avatar asked Oct 24 '25 19:10

zesla


2 Answers

There is a neat package was built called rintrojs which gives you the ability to describe the operations of the shiny app, you can wrap any object into it. More example can be found here https://github.com/carlganz/rintrojs

library(shiny)
library(rintrojs)

ui <- fluidPage(
    introjsUI(),
    column(2,
           br(),
           actionButton("help", "About this Page")
    ),
    column(2,
           introBox(
               selectInput("Task", label = "Select Task",choices =  c("Please select","Upload","Analyze Data")),
               data.step = 1,data.intro = "This is the selectInput called Task, you do xyz with this"
           )
    ),
    column(2,
           introBox(
               selectInput(
                   "breaks", "Breaks",
                   c("Sturges",
                     "Scott",
                     "Freedman-Diaconis",
                     "[Custom]" = "custom")),
               data.step = 2,data.intro = "This is the selectInput called breaks, you do xyz with this"
           )
    ),
    column(2,
           introBox(
               sliderInput("breakCount", "Break Count", min=1, max=1000, value=10),
               data.step = 3,data.intro = "This is the sliderInput called breakCount, you do xyz with this"
           )
    )
)


# Define server logic required to draw a histogram
server <- function(input, output,session) {
    observeEvent(input$help,
                 introjs(session, options = list("showBullets"="false", "showProgress"="true", 
                                                 "showStepNumbers"="false","nextLabel"="Next","prevLabel"="Prev","skipLabel"="Skip"))
    )

}

# Run the application 
shinyApp(ui = ui, server = server)

enter image description here

like image 156
Pork Chop Avatar answered Oct 26 '25 10:10

Pork Chop


Here are 2 possibilities using 'dropMenu()' from the shinyWidgets package and a modal dialogue as suggested in the comments. In this example a button is placed in the dashboard header that opens an information panel or an action button in the dashboard body can be clicked to bring up a separate window.

Placing a button in the dashboard header will allow it to persist regardless of the tab that is activated. This might be helpful if the menu needs to always be accessed.

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
  dashboardHeader( title = "app",
                   tags$li(class = "dropdown",
                           dropMenu(
                             dropdownButton("Info", status = 'success', icon = icon('info')),
                             h3(strong('Information')),
                             br(),
                             h5('This is really helpful'),
                             textInput('text', 'You can also put UI elements here'),
                             placement = "bottom",
                             arrow = TRUE)

                   )

  )
  ,
  dashboardSidebar(),
  dashboardBody(actionButton('help', 'Help'))
)

server <- function(input, output) { 

  observeEvent(input$help,{
    showModal(modalDialog(
      title = "Help!",
      "Information",
      textInput('text2', 'You can also put UI elements here')
    ))
  })
  }

shinyApp(ui, server)

enter image description here enter image description here

like image 44
bs93 Avatar answered Oct 26 '25 10:10

bs93



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!