css - Shiny 应用程序中的可折叠框

标签 css r shiny shinydashboard

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

  includeCSS(path = "AdminLTE.css"), #added 
  includeCSS(path = "shinydashboard.css"), #added

   # Application title
   titlePanel("Old Faithful Geyser Data"),

   # Sidebar with a slider input for number of bins 
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),

      # Show a plot of the generated distribution
      mainPanel(
         box(plotOutput("distPlot"), solidHeader = T, collapsible = T, title = "collapsible box not collapsing", status = "primary")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

   output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
}

# Run the application 
shinyApp(ui = ui, server = server)

这个结果是

enter image description here

在上图中,当单击最小化按钮时,可折叠框不会折叠。

我已经在工作目录中添加了附加的 AdminLTE.cssshinydashboard.css 文件,但问题仍然存在。

最佳答案

仅在 shiny 内使用可折叠框。我们需要添加所需的 javascript。在添加 css 之后,我们添加 this文件也是如此。

  includeCSS(path = "AdminLTE.css"), #added 
  includeCSS(path = "shinydashboard.css"), #added

  #add this file and collapsible nature should work.
  includeScript(path = "app.js"), # 

关于css - Shiny 应用程序中的可折叠框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40584804/

相关文章:

javascript - Accordion 不将该类应用于下一个元素

r - 如何在导航栏页面布局中插入值框?

colors - Shiny 的checkboxgroupinput动态背景颜色控制

html - 我的类 flex wrap 不适用于 div 元素

javascript - 现代浏览器是否像图像一样支持 HTML 中的 base64 编码的 JS 或 CSS block ?

javascript - 在按下选项卡时它不会移动到下一个选项卡

r - 将函数应用于 data.table 中的复杂子集

r - R中线性回归截距的置信区间

python - python 与 R 中的 glm

r - R Shiny 中的预训练模型