spsGoTop: Go top button

Description Usage Arguments Details Value Examples

Description

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.

Usage

1
2
3
4
5
6
7
spsGoTop(
  id = "gotop",
  icon = NULL,
  right = "1rem",
  bottom = "10rem",
  color = "#337ab7"
)

Arguments

id

element ID

icon

shiny::icon if you do not want to use the default rocket image

right

character string, css style, the button's position to window right

bottom

character string, css style, the button's position to window bottom

color

color of the icon.

Details

The button hides if you are on very top of the page. If you scroll down 50px, this button will appear.

Value

a shiny component

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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("home"), color = "red"),
        spsGoTop("up", right = "95%",  bottom= "95%", icon = icon("arrow-up"), color = "green")
    )

    server <- function(input, output, session) {

    }

    shinyApp(ui, server)
}

spsComps documentation built on Feb. 3, 2022, 1:07 a.m.