在闪亮应用程序的可反应单元格中垂直对齐文本

问题描述 投票:0回答:1

是否有办法在闪亮的应用程序中以可反应的方式垂直对齐(中间)单元格中的文本?

下面的最小示例。我尝试了一些CSS选项,但到目前为止还没有运气。

library(shiny)
library(reactable)

ui <- fluidPage(
  titlePanel("reactable example"),
  reactableOutput("table")
)

server <- function(input, output, session) {
  output$table <- renderReactable({
    reactable(iris)
  })
}

shinyApp(ui, server)

谢谢

r shiny react-table
1个回答
0
投票

您可以使用defaultColDef设置默认属性。下面的代码段应使文本垂直居中对齐:

library(shiny)
library(reactable)

ui <- fluidPage(
    titlePanel("reactable example"),
    reactableOutput("table")
)



server <- function(input, output, session) {
    output$table <- renderReactable({
        reactable(iris, 
                  defaultColDef = colDef(
                      align = "center")
                  )
    })
}

shinyApp(ui, server)

下面是运行代码后的输出。输出在中心和水平都对齐

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.