add a go top button on your shiny app. When the user clicks the button, scroll the window all the way to the top. Just add this function anywhere in you UI.
spsGoTop(
id = "gotop",
icon = NULL,
right = "1rem",
bottom = "10rem",
color = "#337ab7"
)
element ID
shiny::icon if you do not want to use the default rocket image
character string, css style, the button's position to window right
character string, css style, the button's position to window bottom
color of the icon.
a shiny component
The button hides if you are on very top of the page. If you scroll down 50px, this button will appear.
if(interactive()){
library(shiny)
ui <- fluidPage(
h1("Scroll the page..."),
lapply(1: 100, function(x) br()),
spsGoTop("default"),
spsGoTop("mid", right = "50%", bottom= "50%", icon = icon("house"), color = "red"),
spsGoTop("up", right = "95%", bottom= "95%", icon = icon("arrow-up"), color = "green")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
}