I want to add space above one of sidebar menu item. For example 'Widgets' in the example below should be shown at the bottom of the page under sidebar (mean there should be space on top of the menu). I tried doing this with tags$div(style = "margin-top: 50px;",
but didn't get desired output.
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
Like the navigation menu bar, the sidebar menu is used on many websites. You can create a nice side menu using basic HTML CSS and JavaScript programming code. I have already designed many more types of sidebar menus. You can follow those tutorials if you want. This is a very simple side menu bar with a profile image and some basic text.
How TO - Fixed Sidebar Step 1) Add HTML: Example <!-- Side navigation --> <div class="sidenav"> <a href="#"> About </a> <a href="#"> Services... Step 2) Add CSS: Example /* The sidebar menu */ .sidenav { height: 100%; /* Full-height: remove this if you want "auto"... W3.CSS Tutorial
How to Create a Full Height Sidebar in CSS To make your sidebar extend to the bottom of the browser window, simply set the height property to 100% in your CSS:
The w3-overlay class can be used to create an overlay effect when opening the sidebar. The w3-overlay class adds a black background with a 50% opacity to the "page content" - this effect will "highlight" the side navigation. The w3-overlay class can be used to create an overlay effect, when opening the sidebar.
You can use this CSS:
css <- "
.sidebar-menu li:not(:last-child) {
margin-bottom: 200px;
}
"
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tags$head(
tags$style(HTML(css))
),
tabItems(
......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With