【问题标题】:Vertically align text in reactable cells in shiny app在闪亮的应用程序中垂直对齐可反应单元格中的文本
【发布时间】:2020-06-15 21:23:05
【问题描述】:

有没有办法在闪亮的应用程序中呈现可反应的单元格中的文本垂直对齐(中间)?

下面的最小示例。我尝试了一些 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】:

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

    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)
    

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

    【讨论】:

    • 感谢您的回复。那没有用。它使文本居中,但没有垂直对齐。它仍然显示在单元格的顶部。
    • 我附上了我得到的输出图像。文本居中和水平对齐。
    • 你是对的。在我的真实数据集上有一个包含图像的列,它弄乱了对齐方式。
    猜你喜欢
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 2021-10-01
    • 2017-09-04
    • 1970-01-01
    • 2018-04-27
    相关资源
    最近更新 更多