Skip to contents

A reusable Shiny module for displaying statistics with an icon, numeric value, and label. Commonly used in dashboards for showing counts, totals, or metrics.

Usage

statsBoxUI(id, icon = "user")

statsBoxServer(id, r_stat_value, stat_label)

Arguments

id

Character. Shiny module namespace ID.

icon

Character. FontAwesome icon name (without fa- prefix). Default: "user".

r_stat_value

Reactive. A reactive expression returning the numeric value to display.

stat_label

Character. Static label text displayed below the value.

Value

statsBoxUI

Shiny UI tagList with styled stats box markup

statsBoxServer

Module server (called for side effects)

Functions

  • statsBoxUI(): Stats box UI component

  • statsBoxServer(): Stats box server component

Styling

The module includes self-contained CSS with:

  • White background with subtle shadow

  • Circular blue icon container

  • Large bold number display

  • Gray label text below

  • Responsive flex layout (4 boxes per row on wide screens)

Examples

if (FALSE) { # \dontrun{
# In UI
statsBoxUI("artwork_count", icon = "palette")

# In server
statsBoxServer(
  "artwork_count",
  r_stat_value = reactive(nrow(artworks_data())),
  stat_label = "Total Artworks"
)
} # }