library(shinydataviewer)
library(shiny)
library(bslib)
#>
#> Attaching package: 'bslib'
#> The following object is masked from 'package:utils':
#>
#> page
library(reactable)The module exposes a small set of customization hooks intended to balance drop-in defaults with downstream flexibility.
data_viewer_server() exposes first-class arguments for
common table controls:
searchablefilterablesortabledefault_page_sizepage_size_optionsFor lower-level reactable() overrides, use
reactable_args.
default_page_size must be one of the values supplied in
page_size_options, and page_size_options must
contain positive integers.
The UI helpers support top or bottom table controls:
Use plot_color on either UI helper to set one CSS color
for all variable summary plots in that viewer. Any CSS color is
supported, including Bootstrap theme variables:
When plot_color is NULL, the plots use the
active Bootstrap primary color.
Use summary_card_fn to replace the default variable card
renderer while keeping the module’s summary computation and table
logic.
The custom function must accept at least summary_row and
index, where summary_row is a one-row data
frame produced by summarize_columns().
custom_summary_card <- function(summary_row, index) {
htmltools::tags$div(
class = "custom-summary-card",
htmltools::tags$strong(summary_row$var_name[[1]]),
htmltools::tags$span(sprintf(" (%s)", summary_row$type[[1]]))
)
}
data_viewer_server(
"viewer",
data = reactive(iris),
summary_card_fn = custom_summary_card
)A typical use case is treating identifier-like columns differently from ordinary categorical fields, for example by suppressing the mini chart and showing a “High cardinality” badge instead.
The module validates unsupported column classes early, so custom
summary-card logic can assume the incoming summary_row
corresponds to one of the supported viewer types.
The module styles use Bootstrap variables, so they follow the active
bslib theme and brand.yml values
automatically.
They also respond to live light and dark mode changes from
bslib::input_dark_mode() and
bslib::toggle_dark_mode().