Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny: color fileInput button and progress bar

Tags:

css

r

shiny

Is there a way to color fileInput button in R shiny? It looks like it is possible as shown here on this page on github. However I cannot find the code for this to be done.

This is the simple application that I would like to modify to have the button and progress bar colored red.

In ui.R:

library(shiny)

shinyUI(fluidPage(
  titlePanel("Test"),
  fileInput("Test","")
))

and server.R

library(shiny)

shinyServer(
  function(input, output) {
  }
)

Thanks for any advice.

like image 806
kolonel Avatar asked Sep 10 '15 06:09

kolonel


1 Answers

You can use standard Bootstrap classes to style action buttons:

library(shiny)

shinyApp(
    ui=shinyUI(bootstrapPage(
        actionButton("infoButton", "Info", class="btn-info"),
        actionButton("warningButton", "Warning", class="btn-warning"),
        actionButton("successButton", "Success", class="btn-success"),
        actionButton("dangerButton", "Danger", class="btn-danger"),
        actionButton("defaultButton", "Default", class="btn-default"),
        actionButton("primaryButton", "Primary", class="btn-primary")
    )),
    server=shinyServer(function(input, output, session){
    })
)

Regarding file inputs as far as I know it is not possible without using CSS directly. Page you've linked is an opened pull-request and it doesn't look like it will be merged soon.

This answer provides a good description how to create fancy upload buttons with bootstrap. It should work just fine in Shiny as well.

like image 189
zero323 Avatar answered Oct 14 '22 23:10

zero323