Reducing space between two box() in R shiny

5.2k views Asked by At

the given script generates a simple histogram plot and a slider within two boxes. I wish to reduce the space between the two boxes and also between their extreme borders with the ends of the screen. Please help and thanks.snapshot of the plots

## app.R ##
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
width = 0
),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(title = "Activity Frequency", status = "primary",height = "520", 
solidHeader = T,
plotOutput("plot1")),
box(title = "Activity Frequency", status = "primary",height = "520", 
solidHeader = T,
sliderInput("slider", "Number of observations:", 1, 100, 50))
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
1

There are 1 answers

0
conv3d On

The answer in the comments did not work for me. After some trial and error, what worked was this:

dashboardBody(tags$head(tags$style(HTML('
.box {margin: 5px;}'
)))

Just include .box {margin: 5px;} in your HTML style tags.