if (interactive()){
library(shiny)
heights <- paste0(c(1.5, 3, 5, 8, 10, 15, 20), "rem")
colors <- list(
colorRampPalette(c("#00d2ff", "#3a7bd5"))(7),
colorRampPalette(c("#59C173", "#a17fe0", "#5D26C1"))(7),
colorRampPalette(c("#667db6", "#0082c8", "#5D26C1", "#667db6"))(7),
colorRampPalette(c("#f2709c", "#ff9472"))(7),
colorRampPalette(c("#FC5C7D", "#6A82FB"))(7),
colorRampPalette(c("#4568DC", "#B06AB3"))(7)
)
types <- c("circle", "dual-ring", "facebook", "heart",
"ring", "roller", "default", "ellipsis",
"grid", "hourglass", "ripple", "spinner")
ui <- fluidPage(
lapply(seq_along(types), function(i){
div(
h4(types[i]), br(),
lapply(1:7, function(x){
cssLoader(
types[i], height = heights[x],
color = colors[[if(i > 6) i - 6 else i]][x],
inline = TRUE
)
}),
br()
)
})
)
server <- function(input, output, session) {}
shinyApp(ui, server)
}
# use with buttons
if (interactive()){
library(shiny)
ui <- fluidPage(
actionButton(
"btn-a", "",
## `inline = TRUE` is important if you want loader and
## text in the same line.
icon = cssLoader(is_icon = TRUE, inline = TRUE, color = "#3a7bd5"
)
),
actionButton(
"btn-b", "Loading",
icon = cssLoader(type = "hourglass", is_icon = TRUE, color = "#667db6", inline = TRUE)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
}
# use your own
if (interactive()){
library(shiny)
spinner <- "https://github.com/lz100/spsComps/blob/master/examples/demo/www/spinner.gif?raw=true"
eater <- "https://github.com/lz100/spsComps/blob/master/examples/demo/www/bean_eater.gif?raw=true"
ui <- fluidPage(
cssLoader(
"gif", spinner, height = "50px"
),
cssLoader(
"gif", spinner, height = "100px"
),
cssLoader(
"gif", eater, height = "150px"
),
cssLoader(
"gif", eater, height = "200px"
),
actionButton(
"btn-custom1", "",
icon = cssLoader(
type = "gif", src = spinner,
is_icon = TRUE, inline = TRUE
)
),
actionButton(
"btn-custom2", "A button",
icon = cssLoader(
type = "gif", src = eater,
is_icon = TRUE, inline = TRUE
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab