1
votes

I have a very basic shiny dashboard and I would like to set the position of this actionbutton exactly in the middle of the sidebar. It must have exactly the same distance from both sidebar sides.

app.R

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
title="Select Data to View or Download",
      titleWidth = 335),
  dashboardSidebar(
width = 335,
actionButton("load","Apply Selections")),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)
2

2 Answers

3
votes

An easier approach (and centered without offset) is to set the button position with the style argument.

actionButton("load", "Apply Selections", style='margin:auto')
1
votes

This can be done by putting it in a column and setting align = "center".

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
    title="Select Data to View or Download",
    titleWidth = 335),
  dashboardSidebar(
    width = 335,
    column(12,align = "center",offset = 0,actionButton("load","Apply Selections"))),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)