Learn R Programming

cardargus (version 0.2.0)

svg_card: Create an Information Card in SVG Format

Description

Generate a complete information card as an SVG with embedded styles, fonts, badges, logos, and field labels/values.

Usage

svg_card(
  title = "FAR",
  badges_data = list(),
  fields = list(),
  bg_color = "#fab255",
  width = 500,
  padding = 20,
  corner_radius = 8,
  font = "Jost",
  title_fontsize = 16,
  title_color = "white",
  label_fontsize = 11,
  value_fontsize = 11,
  label_color = "white",
  value_bg_color = "#f8f8ff",
  value_text_color = "#212529",
  show_house_icon = TRUE,
  logos = list(),
  logos_height = 40,
  bottom_logos = list(),
  bottom_logos_height = 30,
  footer = NULL,
  gap_to_footer = 6,
  footer_row_padding_bottom = 6,
  footer_fontsize = 8,
  footer_color = "white",
  uniform_row_height = TRUE,
  show_viewer = interactive()
)

Value

SVG string

Arguments

title

Card title (e.g., "FAR", "FNHIS")

badges_data

List of badge data (label, value, color)

fields

List of field rows, each row is a list of fields with label, value, and optionally with_icon. The with_icon parameter can be:

  • TRUE - uses the default house icon

  • FALSE or NULL - no icon

  • A character string - path to an SVG file or raw SVG code

bg_color

Background color of the card

width

Card width in pixels

padding

Padding inside the card

corner_radius

Corner radius for rounded corners

font

Font family

title_fontsize

Title font size

title_color

Color for the card title (default "white")

label_fontsize

Label font size

value_fontsize

Value font size

label_color

Color for field labels (default "white")

value_bg_color

Background color for value boxes

value_text_color

Text color for values

show_house_icon

Show house icon next to empreendimento

logos

Character vector of logo file paths or SVG strings for top right. Use get_svg_path("filename.svg") for bundled logos, or any local path.

logos_height

Height for top-right logos (default 40)

bottom_logos

Character vector of logo file paths or SVG strings for bottom left.

bottom_logos_height

Height for bottom-left logos (default 30)

footer

Footer text (e.g., update timestamp)

gap_to_footer

Distance (px) between the last info block and the footer row.

footer_row_padding_bottom

Bottom padding (px) under the footer row (text + logos).

footer_fontsize

Footer font size

footer_color

Color for footer text (default "white")

uniform_row_height

If TRUE, keep the height inside a row.

show_viewer

If TRUE (and interactive), preview the SVG in the Viewer.

Examples

Run this code
# With default house icon
fields <- list(
  list(
    list(label = "Empreendimento", value = "CAIARA II", with_icon = TRUE)
  )
)

# With custom icon
custom_icon <- ''
fields <- list(
  list(
    list(label = "Projeto", value = "Meu Projeto", with_icon = custom_icon)
  )
)

badges <- list(
  list(label = "UH", value = "192"),
  list(label = "Recurso Federal", value = "36,4 milhões")
)

# With file paths for logos
svg_card("FAR", badges, fields, 
         bg_color = "#fab255",
         logos = c("path/to/logo1.svg", "path/to/logo2.svg"),
         bottom_logos = c("path/to/gov_logo.svg"))

Run the code above in your browser using DataLab