繁体   English   中英

在 R Shiny 中包含通过 `bslib` 辅助函数输入时的导航栏高度

[英]Navbar height when Including input through `bslib` helper functions in R Shiny

我正在尝试将常规 shiny 输入放在navbarPage的右侧,但有一些问题。 当我不包含输入(在这种情况下为selectInput )时,导航栏的高度更小且更紧凑,但是当我包含输入时,导航栏的高度增长到 ~85px 并且组件未对齐。 我已经为此苦苦挣扎了一段时间,而我的研究并没有为我带来任何胜利。 有人可以帮我指出正确的方向吗?

截屏

在此处输入图像描述

代码

这是我为上面的屏幕截图整理的示例代码。

library(shiny)
library(shinyWidgets)
library(bslib)

ui <- navbarPage(
    theme = bs_theme(version = 5, bootswatch = 'sandstone'),
    tags$style(type = 'text/css', 'body {padding-top: 70px;}'),

    title = 'Test', 
    id = 'Test',
    fluid = TRUE,
    useShinydashboard(),
    tabPanel('Panel One',
       sidebarLayout(
         sidebarPanel(
           HTML('There once was a man')
         ),
         
         # Show a plot of the generated distribution
         mainPanel(
           HTML('from Nantucket')
         )
      )
    ),
    nav_spacer(),
    nav_item(
          selectInput('view_options_auto_refresh_rate', '',
                      choices = list(
                        'No Auto Refresh' = Inf,
                        '1 Minute Refresh' = 60,
                        '10 Seconds Refresh' = 10,
                        '5 Seconds Refresh' = 5,
                        '1 Second Refresh' = 1
                      ),
                      selected = Inf
          )
    )
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

我确实发现复选框或操作按钮没有相同的问题。 只是选择输入。

这是来自 RShiny 论坛 ( https://community.rstudio.com/t/navbar-height-when-including-input-through-bslib-helper-functions/144970 ) 的交叉帖子。 我有一段时间的问题,但没有答案。 我希望在这里发帖可以扩大受众范围。

谢谢

把你的风格改成这个

    tags$style(HTML(
        '
        .nav.navbar-nav .form-group.shiny-input-container {margin-bottom: 0; height: 38px;}
        .nav.navbar-nav .form-group.shiny-input-container > label {display: inline;}
        '
    )),

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM