Lock R on the side panel of the dashboard (shinydashboard)

I'm looping while creating a Shiny Dashboard in R (using the package shinydashboard). I want to lock the sidebar so that it doesn't scroll when I view the contents of my tabs, but I'm not sure how to do this.

As an example, the following code block will create a long scroll. It would be nice to lock the sidebar so that you can still see the menu tabs while scrolling through the obscene data table.

library(ggplot2)  ## for mpg dataset
library(shinydashboard)

## ui
ui <- dashboardPage(
  dashboardHeader(title="MPG Data"), 
  dashboardSidebar(sidebarMenu(menuItem("MPG", tabName="mpg"))), 
  dashboardBody(tabItems(tabItem(tabName="mpg", fluidRow(tableOutput("mpgTable"))))))

## server
server <- function(input, output) {
  output$mpgTable <- renderTable({mpg})
}

## launch dashboard 
shinyApp(ui, server)
+4
source share
3 answers

You just need to add style = "position: fixed; overflow: visible" style in the ui sidebar.

library(ggplot2)  ## for mpg dataset
library(shinydashboard)

## ui
ui <- dashboardPage(
  dashboardHeader(title="MPG Data"), 
  dashboardSidebar(
    sidebarMenu(style = "position: fixed; overflow: visible;",
      menuItem("MPG", tabName="mpg"))), 
  dashboardBody(
    tabItems(
      tabItem(tabName="mpg", 
       fluidRow(tableOutput("mpgTable"))))))

## server
server <- function(input, output) {
  output$mpgTable <- renderTable({mpg})
}

## launch dashboard 
shinyApp(ui, server)
+2
source

** : css

DT , , ( , ), :

css :

.sidebar {
    color: #FFF;
    position: fixed;
    width: 220px;
    white-space: nowrap;
    overflow: visible;
}
Hide result

.css , "www", ui ; "style.css".

ui :

dashboardPage(
  dashboardHeader(title="MPG Data"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("MPG",tabName="mpg")
    )
  ),
  dashboardBody(
    #here where you throw the css into the header
    tags$head(
      includeCSS('www/style.css')
      ),
    tabItems(
      tabItem(tabName="mpg",
        fluidRow(tableOutput("mpgTable"))
        )
      )
    )
  )

, , DT , . DT package ref.

, .

+6

@HipHopPhysician , ? DT ... ; :

library(ggplot2)
library(DT)
library(shinydashboard)

ui <- 
  dashboardPage(
    dashboardHeader(title="MPG Data"),
    dashboardSidebar(
      sidebarMenu(
        menuItem("MPG",tabName="mpg")
        )
      ),
    dashboardBody(
      #here where you throw the css into the header
      tags$head(
        includeCSS('www/style.css')
      ),
      tabItems(
        tabItem(tabName="mpg",
                dataTableOutput("mpgTable"))
      )
    )
  )

server <- function(input, output) {
  output$mpgTable <- renderDataTable({ mpg })
}
0
source

All Articles