将标题添加到 shinydashboard tabBox

Add caption to shinydashboard tabBox

我想在 shinydashboard 选项卡下方添加一行 HTML 文本。下面的脚本将文本添加到下一列的顶部。

如何在 tabBox 正下方添加一行 HTML 文本。它类似于标题。

library("shiny")
library("shinydashboard")

shinyApp(
  ui = dashboardPage(
    dashboardHeader(disable = TRUE),
    dashboardSidebar(width = 0),

    body <- dashboardBody(
      fluidRow(
        tabBox(
          id = "tabset1", height = "250px",
          tabPanel("Tab1", "First tab content"),
          tabPanel("Tab2", "Tab content 2")
        ),
        htmlOutput("last_updated")
      )
    )
  ),
  server = function(input, output) {
    # The currently selected tab from the first box
    output$tabset1Selected <- renderText({
      input$tabset1
    })
    
    output$last_updated <- renderText({
      paste("<font size='1px;'>Place this caption beneath the tab box</font>") 
    })
  }
)

一个选择是创建一个新的 fluidRow

library(shiny)
library(shinydashboard)

shinyApp(
  ui = dashboardPage(
    dashboardHeader(disable = TRUE),
    dashboardSidebar(width = 0),
    
    body <- dashboardBody(
      fluidRow(
        tabBox(
          id = "tabset1", height = "250px",
          tabPanel("Tab1", "First tab content"),
          tabPanel("Tab2", "Tab content 2")
        ),
      ),
      fluidRow(htmlOutput("last_updated"))
    )
  ),
  server = function(input, output) {
    # The currently selected tab from the first box
    output$tabset1Selected <- renderText({
      input$tabset1
    })
    
    output$last_updated <- renderText({
      paste("<font size='1px;'>&ensp;&ensp;&ensp;Place this caption beneath the tab box</font></p>") 
    })
  }
)

使用 flexbox:

library("shiny")
library("shinydashboard")

shinyApp(
  ui = dashboardPage(
    dashboardHeader(disable = TRUE),
    dashboardSidebar(width = 0),
    
    body <- dashboardBody(
      div(
        style = "display: flex; flex-direction: column;",
        tabBox(
          id = "tabset1", height = "250px",
          tabPanel("Tab1", "First tab content"),
          tabPanel("Tab2", "Tab content 2")
        ),
        htmlOutput("last_updated")
      )
    )
  ),
  server = function(input, output) {
    # The currently selected tab from the first box
    output$tabset1Selected <- renderText({
      input$tabset1
    })
    
    output$last_updated <- renderText({
      paste("<font size='1px;'>Place this caption beneath the tab box</font>") 
    })
  }
)