繁体   English   中英

对齐checkboxInput和闪亮的框标题

[英]Aligning checkboxInput along with the box title in shiny

我有一个闪亮的应用程序,其中我试图在图形上方提供一个复选框供用户选择。 当前,复选框显示在标题下方,而我希望标题位于左侧,而复选框则位于右侧。 我确信可以通过重新编码CSS来实现,但是不知道如何实现。 当前代码如下:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
    dashboardHeader(
        title = "MODULE",titleWidth = 225
    ),
    dashboardSidebar(
        width = 225,
        sidebarMenu(id = "tabs",
                    menuItem("TOPLINES", tabName = "tplines", icon = shiny::icon("dashboard"))
        )),
    dashboardBody(
        tabItems(
            tabItem(
                tabName = "tplines",
                fluidRow(
                    box(
                        checkboxInput(inputId = "inventorytop8metrocheck", "Add to reports", value = FALSE),
                        width = 6, status = "info", title = "Inventory information",
                        div(plotlyOutput("inventorytop8metro"), width = "100%", height = "400px", style = "font-size:80%;")
                    )
                    )))))

server <- function(session,input,output){

}

shinyApp(ui,server)

也许您只是在寻找带columns的标准行分区。 标题争论包含任何ui元素,因此我们输入的行是原始标题的一半,而复选框输入的一半。 因此,它们是一致的。 当然,该复选框与标题具有相同的样式。 如果不希望这样,可以通过在复选框列中设置style参数来更改样式。

library(shiny)
library(shinydashboard)
library(plotly)

ui <- dashboardPage(
  dashboardHeader(
    title = "MODULE",titleWidth = 225
  ),
  dashboardSidebar(
    width = 225,
    sidebarMenu(id = "tabs",
      menuItem("TOPLINES", tabName = "tplines", icon = shiny::icon("dashboard"))
  )),
  dashboardBody(
    tabItems(
      tabItem(
        tabName = "tplines",
        fluidRow(
          box(
            width = 6, status = "info", title = fluidRow(
              column(6, "Inventory information"),
              column(6, checkboxInput(inputId = "inventorytop8metrocheck", "Add to reports", value = FALSE))
            ),
            div(plotlyOutput("inventorytop8metro"), width = "100%", height = "400px", style = "font-size:80%;")
          )
        )
      )
    )
  )
)

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

shinyApp(ui,server)

暂无
暂无

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

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