首页 > 解决方案 > 有没有办法创建一个“?” r闪亮的图标操作按钮?

问题描述

我想知道是否有办法创建一个“?” 图标按钮,单击它会显示一条弹出消息,解释我的模型背后的原因。另外,我如何使它与我的 numericInput 小部件水平内联。

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)

我尝试过的第二个解决方案也给我带来了问题。

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
    ))
})


}

标签: rshiny

解决方案


尝试这个:

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)

推荐阅读