Premium value box components with gradient backgrounds and responsive design. Provides consistent metric display across browse and collection info modules. Each box shows a single metric with icon, label, and formatted value.
Use this for displaying collection statistics (totals, averages) in the browse interface. The boxes auto-format numeric values with commas and handle NULL/NA gracefully by displaying em-dash. Supports optional tooltips for metric explanations.
These components are used internally by [modBrowseServer()] and [collectionInfoServer()] but are exported for custom statistics displays.
Usage
enhancedStatsUI(
id,
label = NULL,
icon = "chart-bar",
color = "primary",
width = 4,
tooltip = NULL
)
enhancedStatsServer(id, value_reactive, subtitle_reactive = NULL)Arguments
- id
Character. Shiny namespace ID for the stats box instance.
- label
Character. Label text describing the metric (e.g., "Total Artworks"). Displayed in the box header alongside the icon.
- icon
Character. FontAwesome icon name without "fa-" prefix (e.g., "palette", "clock", "certificate"). Default "chart-bar".
- color
Character. Color theme: "primary" (purple gradient) or "secondary" (gold gradient). Default "primary".
- width
Numeric. Bootstrap column width (1-12). Default 4 for 3-column layout. Use 3 for 4-column layout.
- tooltip
Character. Optional tooltip text explaining the metric. Shows on hover over the entire stats box. Default NULL (no tooltip).
- value_reactive
Reactive expression returning the main value to display. Can be numeric (auto-formatted with commas), character string, or `shiny::HTML()` for custom formatting. Returns em-dash for NULL/NA/Inf.
- subtitle_reactive
Reactive expression returning optional subtitle text. Displayed below the main value. Default NULL.
Value
`enhancedStatsUI()` returns a `shiny.tag` (column element) containing the stats box with header, value output, and optional subtitle. `enhancedStatsServer()` returns NULL (invisible); called for side effects.
Functions
enhancedStatsUI(): Enhanced value box UI componentenhancedStatsServer(): Enhanced value box server logic
See also
* [modBrowseServer()] which uses these components for collection statistics * [collectionInfoUI()] and [collectionInfoServer()] for alternative stats layout
Other ui-modules:
collectionInfo
Examples
if (FALSE) { # \dontrun{
# In UI
enhancedStatsUI(ns("stat1"),
label = "Total Artworks",
icon = "palette",
color = "primary",
width = 3,
tooltip = "Number of artworks in collection"
)
# In server
enhancedStatsServer("stat1", reactive({
scales::label_comma()(nrow(artworks_data()))
}))
} # }
