R Shiny 的下载按钮与其他输入元素(如 dateInput)对齐

标签 r shiny

我有一个 R Shiny 应用程序,带有不同的下载按钮,如下面的代码所示。问题在于,fluidRow 中下载按钮的位置不会自动与其他输入元素(例如下面的 dateInput)的位置对齐。

ui <- dashboardPage(  
  title = "Test Dashboard",  # this is the name of the tab in Chrome browserr
  dashboardHeader(title = "Web Portal"),
  
  dashboardSidebar(   
    sidebarMenu(

      menuItem('Retail', tabName = "retail", icon = icon("th"),
               menuItem('Dashboard', tabName = 'retail_dashboard'))
    )
  ),

  dashboardBody( 
      tabItem(tabName = "retail_dashboard",
              tabsetPanel(type = "tabs",
                          tabPanel("Dashboard",
                                   h3("Test."),
                                   
                                   fluidRow(column(2,
                                                   dateInput("idx_muni_tot_ret_start_dt", label = "Start Date:", value = Sys.Date()-10)), #  1yr ago
                                            column(2,
                                                   dateInput("idx_muni_tot_ret_end_dt", label = "End Date:", value = Sys.Date())),
                                            column(2,
                                                   downloadButton("download_idx_muni_TR_data","Download Data"))
                                            )
                                     )
                                    )           
              )
              )
)


server <- function(input, output, session) {    
  # code...
}

cat("\nLaunching   'shinyApp' ....")
shinyApp(ui, server)

我在这里发现了类似的问题How do I align downloadButton and ActionButton in R Shiny app?在这里 Change download button position in a tab panel in shiny app但他们似乎没有回答我的问题。我还附上了一张屏幕截图,其中包含当前按钮位置以及预期按钮位置。 enter image description here

最佳答案

解决方法是在下载按钮顶部模拟标签并添加 5px 的 margin-bottom。

column(
  width = 2,
  div(tags$label(), style = "margin-bottom: 5px"),
  div(downloadButton("download_idx_muni_TR_data", "Download Data"))
)

enter image description here

关于R Shiny 的下载按钮与其他输入元素(如 dateInput)对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75210155/

相关文章:

r - 混合模型的 Lme4 语法

python - 如何使用 rpy2 访问 R 包的内部函数?

r - 如何通过 shinyheatmaply 部署交互式热图

r - 在 Shiny 应用程序中创建动态选项卡集会在 ggploty 上出现错误

r - 我可以在 Shiny 的 onSessionEnded 事件中访问 session 值吗?

r - 无法在 R 中加载新的 ggplot2

r - 在 R 版本 3.0.2 上安装 Rtools

r - 如何使用 r 中的 if 条件基于其他列创建新列

shiny - 使用 Shiny 和 renderImage() 预渲染图像的灵活宽度和高度

r - 如何 setView 从 selectInput 中的列表中选择