Skip to content

Instantly share code, notes, and snippets.

@matt-dray
Last active January 8, 2024 13:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matt-dray/cda4a3facb6b1ca848a8ddbcc885a669 to your computer and use it in GitHub Desktop.
Save matt-dray/cda4a3facb6b1ca848a8ddbcc885a669 to your computer and use it in GitHub Desktop.
Make a shields.io README badge that links to a Shiny app, using the {badgr} package in R
# Make a README badge for your R Shiny repo
# Matt Dray, March 2021
# {badgr} blog post: https://www.rostrum.blog/2020/05/08/readme-badge/
# Shiny badge blog post: https://www.rostrum.blog/2021/03/23/shiny-badge/
# {badgr} is available from GitHub via {remotes}
install.packages("remotes") # if not already installed
remotes::install_github("matt-dray/badgr") # install {badgr}
# Generate badge URL and wrap in Markdown link
badgr::get_badge(
# Badge label
label = "Shiny", # left-side text
label_color = "white", # left-side colour
# Badge message
message = "shinyapps.io", # right-side text
color = "blue", # right-side colour
# Logo
logo_simple = "RStudio", # named icon from simpleicons.org
logo_color = "blue", # colour of simpleicons.org icon
# Markdown link
md_link = "https://matt.dray.shinyapps.io/randoflag/", # clickable link URL
# Convenience arguments
browser_preview = TRUE, # preview badge in your browser
to_clipboard = TRUE # copies markdown to paste into readme
)
# Paste into your README, or any other (R) Markdown docs
@matt-dray
Copy link
Author

The code above generates this markdown and copies it to your clipboard ready for pasting in a README:

[![](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://matt.dray.shinyapps.io/randoflag/)

Which renders like this:

@englianhu
Copy link

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