1

I was wondering if there is a way to create a "?" icon button that when clicked it shows a pop up message explaining why behind my model. Also how would I make it horizontally inline with with my numericInput widget.

fileInput("file1", "Choose CSV File",
    accept = c("text/csv",
               "text/comma-separated-values,text/plain",
               ".csv")
),

helper(shiny_tag, icon = "question-circle", colour = NULL,
    type = "markdown", title = "Help", content = "Content", size= "m", 
    buttonLabel = "Okay", easyClose = TRUE, fade = FALSE)

The second solution I have tried was also giving me issues as well.

actionButton("show", "Show modal dialog"), 

server <- function(input, output) {

observeEvent(input$show, {
    showModal(modalDialog(
        title = "Somewhat important message",
        "This is a somewhat important message.",
        easyClose = TRUE,
        footer = NULL
    ))
})


}
  • 1
    Welcome to SO, Crystal Wai! StackOverflow tends to be more about concrete programming examples and problems, not open-ended or theoretical. Please read from https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info to see what is meant by MWE and how to better frame your question. Lacking any changes, this will likely be closed (or ignored) as "needs focus". Thanks! – r2evans Jul 01 '21 at 18:29
  • 1
    (It seems easy enough to use `shiny::actionButton` and `shiny::modalDialog` to do the basics there. Alignment with your other inputs is based on a UI we know nothing about ...) – r2evans Jul 01 '21 at 18:31
  • @r2evans thank you! I hope I improved my question. I am slowly learning how to use this language, sorry for original vagueness. – student_1999 Jul 01 '21 at 18:57
  • Getting better, thank you! It still has room for improvement. For starters: (1) you mention keeping it aligned with a `numericInput` but we don't see how the UI is setup; (2) as such, having functional/complete (albeit still minimal) `ui` and `server` components is a good start. We don't need all of the reactive blocks that do not relate to the question (an unused input is still relevant, an unplotted plot is fine, etc). Thanks! – r2evans Jul 01 '21 at 19:00
  • I see, I will continue to improve my posts in the future! Thank you so much for your feedback! – student_1999 Jul 03 '21 at 02:45

1 Answers1

1

Try this:

library(shiny)
ui <- fluidPage(
  div(
    class = "input-group",
    tags$span(
      style = "display: inline-block",
      numericInput("a", "Some number", 0, width = "100%")
    ),
    tags$span(
      style = "vertical-align: bottom;",
      actionButton("b", "", icon = icon("question"))
    )
  )
)

server <- function(input, output, session) {
  observeEvent(input$b, {
    showModal(modalDialog(
      title = "Somewhat important message",
      "This is a somewhat important message.",
      easyClose = TRUE,
      footer = NULL
    ))
  })
}

shinyApp(ui, server)
lz100
  • 6,990
  • 6
  • 29