cardargus includes several SVG icons for common use cases:
library(cardargus)
# House icon (default for fields with with_icon = TRUE)
icon_house(width = 50, height = 56)
# Building icon
icon_building(width = 50, height = 56)
# Construction icon
icon_construction(width = 50, height = 56)
# Map pin icon
icon_map_pin(width = 50, height = 56)
# Money icon
icon_money(width = 50, height = 56)Icons can be added to fields in three ways:
icon_building()fields <- list(
# Default house icon
list(
list(label = "Project", value = "Housing Complex", with_icon = TRUE)
),
# Built-in building icon
list(
list(label = "Building", value = "Tower A",
with_icon = icon_building())
),
# Construction icon
list(
list(label = "Status", value = "Under Construction",
with_icon = icon_construction())
),
# Custom SVG file path
list(
list(label = "Custom", value = "My Item",
with_icon = "/path/to/my_icon.svg")
)
)
card <- svg_card(
title = "PROJECT",
badges_data = list(),
fields = fields,
bg_color = "#3498db"
)All icons accept customization parameters:
The package includes several SVG logos ready to use:
Logos can be file paths or SVG strings:
card <- svg_card(
title = "FAR",
badges_data = list(
list(label = "Units", value = "192", color = "white")
),
fields = list(...),
bg_color = "#fab255",
# Top-right logos (bundled or custom paths)
logos = c(
get_svg_path("morar_bem.svg"),
get_svg_path("seduh.svg"),
"/path/to/my_custom_logo.svg" # Any local file
),
logos_height = 40,
# Bottom-left logos
bottom_logos = c(
get_svg_path("gov_pe3.svg")
),
bottom_logos_height = 35
)Use load_svg_for_embed() to load and resize external SVG
files:
For advanced positioning, use the logo row functions:
# Top-right logo row
logo_row <- create_logo_row(
logos = c("logo1.svg", "logo2.svg"),
target_height = 40,
spacing = 15,
card_width = 500,
x_offset = 20,
y_offset = 20
)
# Bottom-left logo row
bottom_row <- create_bottom_logo_row(
logos = c("logo3.svg"),
target_height = 30,
spacing = 10,
x_offset = 20,
card_height = 400,
y_offset = 20
)You can use any SVG string as a logo:
# Create a simple custom logo
my_logo <- '<svg width="50" height="50" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="20" fill="#3498db"/>
<text x="25" y="30" text-anchor="middle" fill="white" font-size="16">AB</text>
</svg>'
# Use in a card
card <- svg_card(
title = "PROJECT",
logos = list(my_logo),
logos_height = 40,
...
)| Element | How to specify |
|---|---|
| Default icon | with_icon = TRUE |
| Built-in icon | with_icon = icon_house() |
| Custom SVG file | with_icon = "/path/to/file.svg" |
| Bundled logo | logos = c(get_svg_path("name.svg")) |
| Custom logo file | logos = c("/path/to/logo.svg") |
| SVG string | logos = list('<svg>...</svg>') |