Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Last active December 7, 2020 02:51
Show Gist options
  • Select an option

  • Save aagarw30/9c60b87e839db05b8dcc to your computer and use it in GitHub Desktop.

Select an option

Save aagarw30/9c60b87e839db05b8dcc to your computer and use it in GitHub Desktop.
R Shiny : Styling the download button - Change the back-ground color, font, font color and style of download button
library(shiny)
shinyServer(function(input, output) {
})
library(shiny)
shinyUI(fluidPage(
titlePanel("Styling Download Button"),
sidebarLayout(
sidebarPanel(
h4("Default CSS styling"),
# default styling
downloadButton('downloadData1', label= 'Download 1'),
tags$hr(),
h4("Styling using tags()"),
downloadButton("download", label="Download with default CSS"),
# Using the class parameter in download button and tags() to define the style
downloadButton("download0", label="Download with style", class = "butt"),
tags$head(tags$style(".butt{background-color:#add8e6;} .butt{color: white;}")), # background color and font color
downloadButton("download1", label="Download with style", class = "butt1"),
# style font family as well in addition to background and font color
tags$head(tags$style(".butt1{background-color:orange;} .butt1{color: black;} .butt1{font-family: Courier New}")),
downloadButton("download2", label="Download with style", class = "butt2"),
# making the font italics this time
tags$head(tags$style(".butt2{background-color:black;} .butt2{color: white;} .butt2{font-style: italic;}"))
),
mainPanel()
)
))
@linuxfree2016

linuxfree2016 commented Aug 5, 2016

Copy link
Copy Markdown

Hi there but where a put this code? i need open a git command?

@aagarw30

aagarw30 commented Dec 5, 2016

Copy link
Copy Markdown
Author

Hello,
Assuming you have loaded the shiny package, after that on console write the following to run this GIST.
runGist("https://gist.github.com/aagarw30/9c60b87e839db05b8dcc")

@baj12

baj12 commented May 15, 2019

Copy link
Copy Markdown

when using dashboard, I had to use !important:

downloadButton("report", "Generate report", class="butt"),
      tags$head(tags$style(".butt{color: black !important;}")), #  font color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment