Last active
December 7, 2020 02:51
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output) { | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
) | |
)) |
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
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")