Skip to contents

This function inserts a gov styled table. Format is with header looking rows and columns

Usage

govTable(
  inputId,
  df,
  caption,
  caption_size = "l",
  num_col = NULL,
  width_overwrite = NULL
)

Arguments

inputId

The id assigned to the component's root element. For Shiny input components this is also the name used to access the value via input$<inputId>.

df

expects a dataframe to create a table

caption

adds a caption to the table as a header

caption_size

adjust the size of caption. One of "s", "m", "l", "xl", with "l" as the default. Any other value throws an error.

num_col

adds numeric class format to these columns

width_overwrite

change width. Need to include width for every column. Columns must add up to 1. Options are three-quarters, two-thirds, one-half, one-third, one-quarter. Default is NULL

Value

A div HTML shiny tag object: a scroll container holding the table, which has inputId as its id. Wide tables scroll sideways inside the container rather than making the whole page scroll.

Details

For very large or interactive tables, consider govReactable() instead. govTable() renders a static HTML table, which becomes slow to render and harder to navigate as the number of rows grows. A warning is emitted when df has more than 50 rows.

See also

Other Govstyle tables tabs and accordions: accordion(), govReactable(), govReactable-shiny, govTabs()

Examples

ui <- shinyGovstyle::gov_page(
  shinyGovstyle::gov_main_layout(
    shinyGovstyle::govTable(
      "tab1",
      shinyGovstyle::transport_data_small,
      "Test",
      "l",
      num_col = c(2,3),
      width_overwrite = c("one-half", "one-quarter", "one-quarter")
    )
  )
)

server <- function(input, output, session) {}

if (interactive()) shinyApp(ui = ui, server = server)