Shiny: How to adjust the width of the tabsetPanel?

后端 未结 4 1456
[愿得一人]
[愿得一人] 2020-12-09 22:56

Here is my app embedded in my site. I want to get rid of the scroll widget below my app, this is due to the width of the tabsetPanel.

I embed the app using this code

4条回答
  •  不思量自难忘°
    2020-12-09 23:31

    A different way to adjust the width of sidebarPanel and tabsetPanel was based on modifying the width property of the col-sm-4 and col-sm-8 CSS classes, respectively.
    Using tag$head and tag$style it is possibile to add CSS directly to the Shiny UI.
    See https://shiny.rstudio.com/articles/css.html for details.
    This is not an elegant solution, but it works correctly.

    Shiny UI

    shinyUI(fluidPage(
      tags$head(
        tags$style(HTML("   
         .col-sm-4 { width: 25%;}
         .col-sm-8 { width: 75%;}
        "))
      ),       
      headerPanel(title = ""),
      sidebarPanel(
        sliderInput("size",
                    "Number of Observations",
                    min = 10,
                    max = 200,
                    value = 95),
    
        sliderInput("mu",
                    "Mean",
                    min = -100, 
                    max = 100,
                    value = 0),
    
        sliderInput("sd",
                    "Standard Deviation",
                    min = 1,
                    max = 6,
                    value = 3),
    
        checkboxInput(inputId = "indiv_obs",
                      label = "Show individual observations",
                      value = FALSE),
    
        checkboxInput(inputId = "density",
                      label = "Show density estimate",
                      value = FALSE),
    
        conditionalPanel(condition = "input.density == true",
                         sliderInput(inputId = "bw_adjust",
                                     label = "Bandwidth Adjustment",
                                     min = 0.2,
                                     max = 2,
                                     value = 1,
                                     step = 0.2))
      ),
      mainPanel(
        tabsetPanel(
          tabPanel("Plot", 
                   plotOutput(
                     outputId = "histogram", 
                     height = "400px",
                     width = "400px")),
          tabPanel("Summary",
                   verbatimTextOutput(outputId = "datsummary"))
        ))
    )
    )
    

提交回复
热议问题