简体   繁体   English

对齐checkboxInput和闪亮的框标题

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

I have a shiny application, where in I am trying to provide a checkbox on top of a graph for the user to select. 我有一个闪亮的应用程序,其中我试图在图形上方提供一个复选框供用户选择。 Currently, the check box is rendered below the title, whereas I want the title on the left hand side and the check box on the right hand side in the same line. 当前,复选框显示在标题下方,而我希望标题位于左侧,而复选框则位于右侧。 I am sure it can be achieved through recoding CSS, but don't know how. 我确信可以通过重新编码CSS来实现,但是不知道如何实现。 The current code looks as follows: 当前代码如下:

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)

Maybe you are just looking for the standard row partition with columns . 也许您只是在寻找带columns的标准行分区。 The title arguement takes any ui elements, so we input a row that is half your original title and half the checkbox input. 标题争论包含任何ui元素,因此我们输入的行是原始标题的一半,而复选框输入的一半。 Thus, they are in line. 因此,它们是一致的。 Of course, the checkbox then has the same style as the title. 当然,该复选框与标题具有相同的样式。 If you don't want that, you can alter the style by setting a style parameter in the checkbox column. 如果不希望这样,可以通过在复选框列中设置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