Build a URL string that generates a shields.io metadata badge. For convenience, this function allows you to embed the URL in Markdown with a link and copies this to the clipboard for use in a README or elsewhere.

get_badge(
  label = "shields.io",
  message = "badge",
  color = "ff0000",
  style = "flat",
  label_color = NULL,
  md_link = NULL,
  link_left = NULL,
  link_right = NULL,
  logo_simple = NULL,
  logo_color = NULL,
  logo_width = NULL,
  logo_path = NULL,
  ext_override = NULL,
  browser_preview = TRUE,
  include_md = TRUE,
  to_clipboard = TRUE
)

Arguments

label

Text string to display on the left side of the badge.

message

Text string to display on the right side of the badge.

color

The background color of the right side of the badge. Should be one of hex, RGB, RGBA, HSL, HSLA or a CSS named color.

style

One of "plastic", "flat", "for-the-badge" or "social". See examples on shields.io.

label_color

The background color of the left side of the badge. Should be one of hex, RGB, RGBA, HSL, HSLA or a CSS named color.

md_link

A URL string to be used in your badge's Markdown output. If used, clicking the rendered HTML badge output will take you to this site.

link_left

A URL string for the left side of the badge. (Included for completeness; you probably want md_link instead)

link_right

A URL string for the right side of the badge. (Included for completeness; you probably want md_link instead)

logo_simple

Text string that names a logo from simple-icons.org to be placed on the far left of the badge. (Use either a named logo with logo_simple or a custom logo with logo_path; not both.)

logo_color

A color for the logo specified by logo_simple.

logo_width

Horizontal spacing width around the logo.

logo_path

URL string for your custom logo image. (Use either a named logo with logo_simple or a custom logo with logo_path; not both.)

ext_override

Provide a file extension that overrides the one in logo_path. (For example, you could specify png or gif if you're using a favicon in ico format.) You're unlikely to need this argument.

browser_preview

Do you want to preview the badge in the browser? Requires an internet connection.

include_md

Do you want to prepare the URL with Markdown syntax (![]()) to allow for direct copying into a Markdown file? Otherwise you get the bare URL. Use md_link to add a link to the badge.

to_clipboard

Do you want the string to be copied to your clipboard so you can paste it elsewhere? Will overwrite your current clipboard items.

Value

A text string.

Examples

get_badge("Label", "Message", "blue", browser_preview = FALSE, to_clipboard = FALSE)
#> [1] "https://img.shields.io/badge/Label-Message-blue?style=flat"