How to display widgets inline in shiny

前端 未结 2 1656
温柔的废话
温柔的废话 2020-12-08 19:50

I have the below code to display the widgets inline(in same row) in shiny

div(style=\"display:inline-block; width: 150px;height: 75px;\",selectInput(\"ddllgr         


        
相关标签:
2条回答
  • 2020-12-08 20:30

    Add vertical-align:top to your style

    rm(list = ls())
    library(shiny)
    
    ui <- fluidPage(
        sidebarPanel(
              div(style="display: inline-block;vertical-align:top; width: 150px;",selectInput("ddllgra", "Function:",c('mean','median','sd','count','min','max'), selected='mean')),
              div(style="display: inline-block;vertical-align:top; width: 150px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))),
        mainPanel()
    )
    server <- shinyServer(function(input,output){})
    shinyApp(ui, server)
    

    Edit: How to add space between the divs

    You can use the same approach: Example below has 100px between the divs

    rm(list = ls())
    library(shiny)
    
    ui <- fluidPage(
      sidebarPanel(
        div(style="display: inline-block;vertical-align:top; width: 150px;",selectInput("ddllgra", "Function:",c('mean','median','sd','count','min','max'), selected='mean')),
        div(style="display: inline-block;vertical-align:top; width: 100px;",HTML("<br>")),
        div(style="display: inline-block;vertical-align:top; width: 150px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))),
      mainPanel()
    )
    server <- shinyServer(function(input,output){})
    shinyApp(ui, server)
    

    0 讨论(0)
  • 2020-12-08 20:32

    You should create a fluidPage with a fluidRow and then use the column function.

         fluidPage(fluidRow(
                            column(2, selectInput()),
                            column(1, selectInput()),
                            column(2, textInput())
                            )
                   )
    

    More detail, look up fluidPage,fluidRow and column within shiny function references: http://shiny.rstudio.com/reference/shiny/latest/

    0 讨论(0)
提交回复
热议问题