Reputation: 8404
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.
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)
Upvotes: 1
Views: 2466
Reputation: 7689
An easier approach (and centered without offset) is to set the button position with the style
argument.
actionButton("load", "Apply Selections", style='margin:auto')
Upvotes: 3
Reputation: 2835
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)
Upvotes: 1