在 R Shiny tabBox 中的选项卡旁边添加按钮

Add button next to tabs in R Shiny tabBox

我在 shiny 仪表板中有一个 tabBox,我想在 tabBox 标题通常出现的选项卡右侧添加一个下载按钮:

关于如何做到这一点有什么建议吗?

这里有一些最简单的代码(没有所需的下载框):

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "tabBoxes"), 
  dashboardSidebar(disable=TRUE), 
  dashboardBody(
    fluidRow(
      tabBox(
        title = 'Download Button',
        width = 12,
        tabPanel("Tab1", "Some text for tab 1"),
        tabPanel("Tab2", "Some text for tab 2")
        )
      ))
  )

server <- function(input, output) { }

shinyApp(ui, server)

结果很简单,只需将 tabBox 标题设置为 downloadButton!

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "tabBoxes"), 
  dashboardSidebar(disable=TRUE), 
  dashboardBody(
    fluidRow(
      tabBox(
        title = downloadButton(outputId = 'downloadData', label='Download'),
        width = 12,
        tabPanel("Tab1", "Some text for tab 1"),
        tabPanel("Tab2", "Some text for tab 2")
        )
      ))
  )

server <- function(input, output) { }

shinyApp(ui, server)