Package 'ROvis.shiny'

Title: Create interactive components for interactive data visualisations in Rijksoverheid style using 'shiny'
Description: Provides a comprehensive suite of utilities for interactive visualisation in Rijksoverheid style.
Authors: ROvis team [cre, aut]
Maintainer: ROvis team <[email protected]>
License: EUPL (>= 1.2)
Version: 0.1.0
Built: 2026-10-21 12:18:55 UTC
Source: https://github.com/rivm-syso/ROvis.shiny

Help Index


Create a Custom Button for Shiny UI

Description

Generates a Shiny action button with an SVG icon and custom label text.

Usage

ro_create_custom_button(input_id, label_text, svg_path)

Arguments

input_id

Character. The input ID for the action button.

label_text

Character. The label to display next to the icon.

svg_path

Character. SVG path data for the icon.

Value

A Shiny tag list representing the action button UI element.

See Also

ro_icon_download, ro_icon_table

Other DT: ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

## Not run: 
ro_create_custom_button(
  input_id = "download_btn",
  label_text = "Download",
  svg_path = ro_icon_download()
)

## End(Not run)

SVG path for download icon

Description

SVG path for download icon

Usage

ro_icon_download()

Value

A character string with the SVG path data for a download icon.

See Also

ro_create_custom_button, ro_icon_table, ro_shiny_graph_panel_server, ro_shiny_graph_panel_ui

Other DT: ro_create_custom_button(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

## Not run: 
download_button <- ro_icon_download()

## End(Not run)

SVG path for table icon

Description

SVG path for table icon

SVG path for table icon

Usage

ro_icon_table()

ro_icon_table()

Value

A character string with the SVG path data for a table icon.

A character string with the SVG path data for a table icon.

See Also

ro_create_custom_button, ro_icon_download

Other DT: ro_create_custom_button(), ro_icon_download(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

## Not run: 
button_table <- ro_icon_table()

## End(Not run)
## Not run: 
icon_table <- ro_icon_table()

## End(Not run)

Button Theme CSS for Shiny Apps (RIVM Style)

Description

Provides RIVM house style CSS for custom icon buttons in Shiny apps. Includes styling for button appearance, hover/active/focus states, icon styling, and button container layout.

Usage

ro_shiny_button_theme()

Value

A shiny.tags object (HTML

tag) to be included at the top of your Shiny UI.

See Also

ro_shiny_skip_link, ro_shiny_skip_link_style, ro_shiny_focus_style, ro_shiny_dt_responsive, ro_create_custom_button, ro_icon_download, ro_icon_table

Other shiny: ro_shiny_dt_responsive(), ro_shiny_focus_style(), ro_shiny_screenreader(), ro_shiny_skip_link(), ro_shiny_skip_link_style()

Examples

if (interactive()) {
  ui <- fluidPage(
    ro_shiny_screenreader(),
    ro_shiny_skip_link(),
    ro_shiny_skip_link_style(),
    ro_shiny_focus_style(),
    ro_shiny_button_theme(),
    ro_shiny_dt_responsive(),
    # ... your app UI ...
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}

Download Button Module Server

Description

Server logic for a download button that exports data as a CSV file using a custom filename.

Usage

ro_shiny_download_server(
  id,
  data_to_download,
  filename_prefix = "data",
  svg_path
)

Arguments

id

Character. The module namespace ID.

data_to_download

Function. A function returning the data to be downloaded (as a data frame or tibble).

filename_prefix

Character. Prefix for the downloaded file name. Default is "data".

svg_path

Character. SVG path data for the icon (not used in server, but included for consistency).

Value

None. Sets up the server logic for the download button module.

See Also

ro_shiny_download_ui, ro_shiny_graph_panel_server

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

# In server function:
if (interactive()) {
ro_shiny_download_server(
  id = "download1",
  data_to_download = function() mydata,
  filename_prefix = "cases",
  svg_path = ro_icon_download()
)
}

Download Button Module UI

Description

Creates a Shiny UI element for a download button with a custom SVG icon and label.

Usage

ro_shiny_download_ui(id, label_text = "Export", svg_path)

Arguments

id

Character. The module namespace ID.

label_text

Character. The label to display on the button. Default is "Export".

svg_path

Character. SVG path data for the icon.

Value

A Shiny UI element (action button) for use in a module UI.

See Also

ro_shiny_download_server, ro_shiny_graph_panel_ui

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

if (interactive()) {
ro_shiny_download_ui(
  id = "download1",
  label_text = "Export",
  svg_path = ro_icon_download()
)
}

Responsive DataTables CSS for Shiny Apps

Description

Provides CSS to make DataTables responsive in Shiny apps. Enables horizontal scrolling for tables on small screens, ensuring tables remain usable on mobile devices and narrow viewports.

Usage

ro_shiny_dt_responsive()

Value

A shiny.tags object (HTML

tag) to be included at the top of your Shiny UI.

See Also

ro_shiny_skip_link, ro_shiny_skip_link_style, ro_shiny_focus_style, ro_shiny_button_theme, ro_shiny_dt_ui

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Other shiny: ro_shiny_button_theme(), ro_shiny_focus_style(), ro_shiny_screenreader(), ro_shiny_skip_link(), ro_shiny_skip_link_style()

Examples

if (interactive()) {
  ui <- fluidPage(
    ro_shiny_screenreader(),
    ro_shiny_skip_link(),
    ro_shiny_skip_link_style(),
    ro_shiny_focus_style(),
    ro_shiny_button_theme(),
    ro_shiny_dt_responsive(),
    # ... your app UI ...
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}

DT Table Module Server

Description

Server logic for rendering an accessible, keyboard-navigable (with customJS) DT table with options for sorting and page length.

Usage

ro_shiny_dt_server(id, data, caption, sorting = FALSE, pagelength = 10)

Arguments

id

Character. The module namespace ID.

data

Data frame or tibble. The data to display in the table.

caption

Character. Table caption/title (displayed above the table).

sorting

Logical. Should column sorting be enabled? Default is FALSE.

pagelength

Integer. Number of rows to display per page. Default is 10.

Value

None. Sets up the server logic for the DT table module.

See Also

ro_shiny_dt_ui, ro_shiny_graph_panel_server

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

# In your Shiny server:
if (interactive()) {
ro_shiny_dt_server(
  id = "table1",
  data = my_data,
  caption = "Aantal gevallen per groep",
  sorting = TRUE,
  pagelength = 20
)
}

DT Table Module UI

Description

Creates a Shiny UI element for displaying a DT (DataTable) table output within a module.

Usage

ro_shiny_dt_ui(id)

Arguments

id

Character. The module namespace ID.

Value

A Shiny UI output element for rendering a DT table.

See Also

ro_shiny_dt_server, ro_shiny_graph_panel_server

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

if (interactive()) {
ro_shiny_dt_ui("table1")
}

Focus Indicators CSS for Shiny Apps

Description

Provides CSS for focus indicators on all interactive elements in Shiny apps. Ensures keyboard users can see which element currently has focus, improving accessibility and keyboard navigation.

Usage

ro_shiny_focus_style()

Value

A shiny.tags object (HTML

tag) to be included at the top of your Shiny UI.

See Also

ro_shiny_skip_link, ro_shiny_skip_link_style, ro_shiny_button_theme, ro_shiny_dt_responsive

Other shiny: ro_shiny_button_theme(), ro_shiny_dt_responsive(), ro_shiny_screenreader(), ro_shiny_skip_link(), ro_shiny_skip_link_style()

Examples

if (interactive()) {
  ui <- fluidPage(
    ro_shiny_screenreader(),
    ro_shiny_skip_link(),
    ro_shiny_skip_link_style(),
    ro_shiny_focus_style(),
    ro_shiny_button_theme(),
    ro_shiny_dt_responsive(),
    # ... your app UI ...
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}

Generic Graph Module Server

Description

Server logic for a generic chart module. Renders a chart using a user-supplied render function and a plot-producing function.

Usage

ro_shiny_graph_mod_server(id, render_fun, plot_data_fun)

Arguments

id

Character. Module namespace ID.

render_fun

Function. A Shiny render function (renderPlotly, highcharter::renderHighchart, echarts4r::renderEcharts4r, etc.).

plot_data_fun

Function. A function returning the data or object to plot.

Value

None. Sets up the server logic for the generic chart module.

See Also

ro_shiny_graph_panel_server, ro_shiny_graph_mod_ui

Other ggplotly: ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui()

Other plotly: ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui()

Other echarts: ro_shiny_graph_panel_server()

Examples

# Using plotly
if (interactive()) {
  ro_shiny_graph_mod_server(
    id = "my_chart",
    render_fun = plotly::renderPlotly,
    plot_data_fun = function() plotly_obj
  )
}
# Using highcharter
if (interactive()) {
  ro_shiny_graph_mod_server(
    id = "my_chart",
    render_fun = highcharter::renderHighchart,
    plot_data_fun = function() highcharter::highchart() |>
      highcharter::hc_add_series(data = c(1,2,3))
  )
}

# Using echarts4r
if (interactive()) {
  ro_shiny_graph_mod_server(
    id = "my_chart",
    render_fun = echarts4r::renderEcharts4r,
    plot_data_fun = function() echarts4r::e_charts(1:3) |> echarts4r::e_line(1:3)
  )
}

Generic yGraph Module UI

Description

Returns a UI output element for a generic chart module, using a user-supplied chart UI function.

Usage

ro_shiny_graph_mod_ui(id, plot_ui_fun)

Arguments

id

Character. Module namespace ID.

plot_ui_fun

Function. A function that generates a UI element for the chart output (plotlyOutput, highcharter::highchartOutput, echarts4r::echarts4rOutput, etc.).

Value

A Shiny UI output element for use in a module UI.

See Also

ro_shiny_graph_panel_ui, ro_shiny_graph_mod_server

Other ggplotly: ro_shiny_graph_mod_server(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui()

Other plotly: ro_shiny_graph_mod_server(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui()

Other echarts4r: ro_shiny_graph_panel_ui()

Examples

# Using plotly
if (interactive()) {
  ro_shiny_graph_mod_ui("my_chart", plotlyOutput)
}

# Using highcharter
if (interactive()) {
  ro_shiny_graph_mod_ui("my_chart", highcharter::highchartOutput)
}

# Using echarts4r
if (interactive()) {
  ro_shiny_graph_mod_ui("my_chart", echarts4r::echarts4rOutput)
}

Graph Panel Module Server

Description

Server logic for the graph panel module. Handles rendering of the chart, toggling and displaying the table, and downloading data.

Usage

ro_shiny_graph_panel_server(
  id,
  plot_render_fun,
  plot_data_fun,
  data,
  caption,
  sorting = FALSE,
  pagelength = 10
)

Arguments

id

Character. Module namespace ID.

plot_render_fun

Function. A Shiny render function (plotly::renderPlotly, highcharter::renderHighchart, etc.).

plot_data_fun

Function. A function returning the data or plot object for the chart.

data

Data frame or tibble. The data to be shown in the table and available for download.

caption

Character. Caption/title for the data table.

sorting

Logical. Should the table allow column sorting? Default is FALSE. When used, apply the same in ro_shiny_graph_panel_ui.

pagelength

Integer. Number of rows per page in the data table. Default is 10.

Value

None. Sets up the server logic for the graph panel module.

See Also

ro_shiny_graph_panel_ui, ro_shiny_graph_mod_server, ro_show_table_server, ro_shiny_download_server, ro_icon_download, ro_shiny_dt_ui, ro_shiny_dt_server

Other ggplotly: ro_shiny_graph_mod_server(), ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_ui()

Other plotly: ro_shiny_graph_mod_server(), ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_ui()

Other echarts: ro_shiny_graph_mod_server()

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

# In your Shiny server:
if (interactive()) {
  ro_shiny_graph_panel_server(
  id = "main",
  plot_render_fun = plotly::renderPlotly,
  plot_data_fun = function() plotly_obj,
  data = my_data,
  caption = "Aantal gevallen per groep",
  sorting = TRUE,
  pagelength = 20
  )
}

Graph Panel Module UI

Description

Generates a Shiny UI module including a chart, skip-link for accessibility, a table toggle button, download button, and a data table area.

Usage

ro_shiny_graph_panel_ui(id, plot_ui_fun, sorting = FALSE)

Arguments

id

Character. Module namespace ID.

plot_ui_fun

Function. UI function to create the chart output (for example plotlyOutput).

sorting

Logical. Should the table allow column sorting? Default is FALSE. When used, apply the same in ro_shiny_graph_panel_server.

Value

A Shiny UI element (tagList) for use in a module UI.

See Also

ro_shiny_graph_panel_server, ro_shiny_skip_link, ro_shiny_skip_link_style, ro_shiny_focus_style, ro_shiny_button_theme, ro_shiny_dt_responsive, ro_shiny_screenreader, ro_icon_download, ro_shiny_graph_mod_ui, ro_show_table_ui, ro_shiny_download_ui

Other ggplotly: ro_shiny_graph_mod_server(), ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_server()

Other plotly: ro_shiny_graph_mod_server(), ro_shiny_graph_mod_ui(), ro_shiny_graph_panel_server()

Other echarts4r: ro_shiny_graph_mod_ui()

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_screenreader(), ro_show_table_server(), ro_show_table_ui()

Examples

if (interactive()) {
  ro_shiny_graph_panel_ui("main", plotlyOutput)
}

Screen Reader Only CSS Classes for Shiny Apps

Description

Provides general-purpose CSS classes that visually hide content while keeping it accessible to screen readers. Includes .sr-only and .visually-hidden classes.

Usage

ro_shiny_screenreader()

Value

A shiny.tags object with a <head> tag containing screen reader only CSS classes.

See Also

ro_shiny_skip_link, ro_shiny_skip_link_style, ro_shiny_dt_ui, ro_shiny_graph_panel_ui

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_show_table_server(), ro_show_table_ui()

Other shiny: ro_shiny_button_theme(), ro_shiny_dt_responsive(), ro_shiny_focus_style(), ro_shiny_skip_link(), ro_shiny_skip_link_style()

Examples

if (interactive()) {
  ui <- fluidPage(
    ro_dt_theme(sorting = FALSE),
    ro_shiny_screenreader(),
    DTOutput("mytable")
  )
  server <- function(input, output, session) {
    output$mytable <- renderDT(datatable(iris, options(list(ordering=FALSE))))
  }
  shinyApp(ui, server)
}

Table Toggle Button Module Server

Description

Server logic for toggling the table visibility button and updating its label/icon.

Usage

ro_show_table_server(
  id,
  svg_path,
  label_show = "Toon tabel",
  label_hide = "Verberg tabel"
)

Arguments

id

Character. The module namespace ID.

svg_path

Character. SVG path data for the icon.

label_show

Character. Label shown when table is hidden. Default is "Toon tabel".

label_hide

Character. Label shown when table is visible. Default is "Verberg tabel".

Value

A list with a reactiveVal show_table, indicating whether the table is shown.

See Also

ro_show_table_ui, ro_shiny_graph_panel_server

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_ui()

Examples

if (interactive()) {
  ro_show_table_server(
    id = "toggle1",
    svg_path = ro_icon_table()
  )
}

Table Toggle Button Module UI

Description

Creates a Shiny action button with an SVG icon to toggle table visibility.

Usage

ro_show_table_ui(
  id,
  label_show = "Toon tabel",
  label_hide = "Verberg tabel",
  svg_path
)

Arguments

id

Character. The module namespace ID.

label_show

Character. Label shown when table is hidden. Default is "Toon tabel".

label_hide

Character. Label shown when table is visible. Default is "Verberg tabel".

svg_path

Character. SVG path data for the icon.

Value

A Shiny UI element (action button) for use in a module UI.

See Also

ro_show_table_server, ro_shiny_graph_panel_ui

Other DT: ro_create_custom_button(), ro_icon_download(), ro_icon_table(), ro_shiny_download_server(), ro_shiny_download_ui(), ro_shiny_dt_responsive(), ro_shiny_dt_server(), ro_shiny_dt_ui(), ro_shiny_graph_panel_server(), ro_shiny_graph_panel_ui(), ro_shiny_screenreader(), ro_show_table_server()

Examples

if (interactive()) {
ro_show_table_ui(
  id = "toggle1",
  svg_path = ro_icon_table()
)
}