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

发布于 2025-01-14 16:21:31 字数 757 浏览 3 评论 0原文

我在 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)

I have a tabBox in a shiny dashboard and would like to add a download button on the right of the tabs where the title of the tabBox would usually appear:

enter image description here

Any suggestions on how to do this?

Here is some minimal code to work with (without the required download box):

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2025-01-21 16:21:31

结果就像将 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)

Turns out its as simple as setting the tabBox title equal to a 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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文