我正在与 bs4dash 合作创建一个 Shiny 应用程序。但是,我无法更改 box() 本身中的空白区域。 headerBorder 的灰线和表格之间总是有相当大的空间。我希望能够使用多余的空白,因此表格尽可能靠近 headerBorder。
library(shiny)
library(bs4Dash)
library(gt)
library(tidyverse)
ui <- dashboardPage(
title = "Example",
header = dashboardHeader(title = "Example"),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
"Page 1",
tabName = "example_page",
icon = icon("e")
)
)),
body = dashboardBody(
tabItems(
tabItem(
tabName = "example_page",
fluidRow(
sortable(
width = 7,
box(title = "Example box",
headerBorder = T,
gt_output("gt_example"),
width = 12,
height = 200)
)
)
)
)
)
)
server <- function(input, output, session) {
output$gt_example <- render_gt({
mpg |> head(2) |> gt()
})
}
shinyApp(ui, server)
的
.card-body
和表 (#gt_example > div
) 的子项设置为 0px
:
library(shiny)
library(bs4Dash)
library(gt)
library(tidyverse)
ui <- dashboardPage(
title = "Example",
header = dashboardHeader(
title = "Example",
tags$head(tags$style(HTML(
".card-body, #gt_example > div {
padding-top: 0px !important;
}")))),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
"Page 1",
tabName = "example_page",
icon = icon("e")
)
)),
body = dashboardBody(
tabItems(
tabItem(
tabName = "example_page",
fluidRow(
sortable(
width = 7,
box(title = "Example box",
headerBorder = T,
gt_output("gt_example"),
width = 12,
height = 200)
)
)
)
)
)
)
server <- function(input, output, session) {
output$gt_example <- render_gt({
mpg |> head(2) |> gt()
})
}
shinyApp(ui, server)