Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to vertically align buttons in separate columns of a Shiny app?

I have a shiny app with two columns, just like this one:


ui <- fluidPage(
  
  fluidRow(
    column(
      width = 2,
      actionButton("myButton0", "Action0"),
      actionButton("myButton1", "Action1"),
      actionButton("myButton2", "Action2")
    ),
    column(
      width = 6,
      downloadButton("myButton3", "Download")
        
      
    )
  )
)

server <- function(input, output) {
}

shinyApp(ui, server)

I want to vertically align the myButton2 button with the myButton3 button, so that they always are displayed at the same height. I can do this using the argument style = "position: relative; left: 0px; top: 213px", but as this moves the button a fixed amount of pixels, the buttons do not align when the display ratio the user changes

Is there a way to reliably align these buttons?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One option would be to use two fluidRows, one for each row of buttons:

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(
      width = 2,
      actionButton("myButton0", "Action0"),
      actionButton("myButton1", "Action1")
    )
  ),
  fluidRow(
    column(
      width = 2,
      actionButton("myButton2", "Action2")
    ),
    column(
      width = 6,
      downloadButton("myButton3", "Download")
    )
  )
)

server <- function(input, output) {
}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading