Search code examples
rshinydashboardshinydashboardsidebar

How to move a tab to the bottom of the sidebar in R Shiny?


I have a shiny dashboard built with shinyDashboardPlus. I have a sidebar with several tabs - as usual, they are aligned in the top left corner.

My sidebar scrolling is fixed with style = "position: fixed;".

I want to add a Help / Contact tab, but I want it to sit in the bottom left corner of the sidebar. How do I do that?


Solution

  • You'll have to style the according li-tag via css.

    Please check the follwing:

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(title = "Simple tabs"),
      dashboardSidebar(
        sidebarMenu(
          menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
          menuItem("Widgets", icon = icon("th"), tabName = "widgets",
                   badgeLabel = "new", badgeColor = "green")
        )
      ),
      dashboardBody(
        tags$head(
          tags$style(HTML("
          #sidebarItemExpanded > ul > :last-child {
            position: absolute;
            bottom: 0;
            width: 100%;
            background-color: red;
          }
    
        "))),
        tabItems(
          tabItem(tabName = "dashboard",
                  h2("Dashboard tab content")
          ),
          tabItem(tabName = "widgets", id = "widgetstabid",
                  h2("Widgets tab content")
          )
        )
      )
    )
    
    server <- function(input, output, session) {
      
    }
    
    shinyApp(ui, server)
    

    result