简体   繁体   中英

Positioning of box and action buttons in R shiny

The following dashboard page consists of action buttons aligned to the left and the plot and two more zoom and reset buttons. I want to position the box at the center of the screen and zoom and reset buttons to the extreme top-right. Rest all buttons are fine. I tried to use tags$div but no help. Please help and big thanks in advance.

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(title = "My Dashboard"),
dashboardSidebar(
width = 0
),
dashboardBody(
                     tags$br(actionButton("go", "Log")),
                     tags$br(),
                     tags$br(actionButton("go", "Case")),
                     tags$br(),
                     tags$br(actionButton("go", "Resource")),
                     tags$br(),
                     tags$br(actionButton("go", "Activity")),
                     tags$br(),
                     tags$br(actionButton("go", "Resource-activity")),
                     box(),
                     tags$br(actionButton("go", "Zoom")),
                     tags$br(actionButton("go", "Reset"))
                     ))

server <- function(input, output)
{ 
}
shinyApp(ui, server)

Something like this do?

  ## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard"),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    fluidRow(
      column(1,
             tags$br(actionButton("go", "Log")),
             tags$br(),
             tags$br(actionButton("go1", "Case")),
             tags$br(),
             tags$br(actionButton("go2", "Resource")),
             tags$br(),
             tags$br(actionButton("go3", "Activity")),
             tags$br(),
             tags$br(actionButton("go4", "Resource-activity"))),
      br(),
      column(10,
             box(width=12,plotOutput("plot"))),
      column(1,
             tags$br(actionButton("go5", "Zoom")),
             tags$br(),
             tags$br(actionButton("go6", "Reset"))))
  ))

server <- function(input, output){ 

  output$plot <- renderPlot(hist(mtcars$disp))

}
shinyApp(ui, server)

在此输入图像描述

You could play with fluidRow and column :

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard"),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    fluidRow(
      column(2, offset = 1,
             actionButton("go", "Log")
      ),
      column(2, offset = 7,
             actionButton("go", "Zoom")
      )
    ),
    fluidRow(
      column(2, offset = 1,
             actionButton("go", "Case")
      ),
      column(2, offset = 7,
             actionButton("go", "Reset")
      )
    ),
    fluidRow(
      column(2, offset = 1,
             actionButton("go", "Resource")
      ),
      column(8, offset = 1,
             box()
      )
    ),
    fluidRow(
      column(2, offset = 1,
             actionButton("go", "Activity")
      )
    ),
    fluidRow(
      column(2, offset = 1,
             actionButton("go", "Resource-activity")
      )
    )
  )
)

server <- function(input, output) {}
shinyApp(ui, server)

But there might be better alternatives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM