Reputation: 618
I am interested in keeping a panel of action buttons FIXED at the top of the page while I am scrolling. How do I do this for either (or both) the base shiny "titlePanel" or the "shinyWidgets::panel"?
My attempt at UI code for the base shiny:
ui <- shinyUI(fluidPage(
titlePanel(style = "position:fixed;width:inherit;",
fluidRow(
column(12, align="center",
actionButton("rmd1", "RMD1"),
actionButton("rmd2", "RMD2")
)
))
,uiOutput("uioutput")
))
My attempt at UI code using shinyWidgets::panel:
ui <- shinyUI(fluidPage(
shinyWidgets::panel(style = "position:fixed;width:inherit;",
fluidRow(
column(12, align="center",
actionButton("rmd1", "RMD1"),
actionButton("rmd2", "RMD2")
)
))
,uiOutput("uioutput")
))
P.S. I am avoiding using "absolutePanel" for a few reasons. 1.) I like how titlePanel and shinyWidgets::panel have their own area of space blocked out. AKA, I like how those options "look." 2.) I have no experience with absolutePanel and dont know how to center, change size, etc.
That being said, if a solution exists with absolutePanel that makes it look like one of the other two options, I am not opposed to trying it.
Upvotes: 1
Views: 1173
Reputation: 33442
You were almost there. You can simply wrap your titlePanel
in a div
to style it:
library(shiny)
ui <- shinyUI(fluidPage(
div(titlePanel(fluidRow(
column(12, align="center",
actionButton("rmd1", "RMD1"),
actionButton("rmd2", "RMD2")
)
)), style = "position:fixed; width:inherit;"),
uiOutput("uioutput", height = "2000px")
))
server <- function(input, output, session) {
output$uioutput <- renderUI({tagList(HTML(rep("...<br>", 100)), hr())})
}
shinyApp(ui, server)
Upvotes: 1