Skip to contents

This function creates a tabs based table. It requires a single dataframe with a grouping variable.

Usage

govTabs(inputId, df, group_col)

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

A single dataframe with all data. See example for structure

group_col

The column name with the groups to be used as tabs

Value

a tab table HTML shiny tag object

Details

Every tab and panel id is prefixed with inputId, so several govTabs() on one page work independently, even when they share the same group values. The first tab is selected when the page loads.

As in the GOV.UK Design System, the tabs become a "Contents" list of links with every table shown on small screens. govTabs() also does this when its tabs do not fit on one row of the space it is given, for example in a two-thirds column on a narrow window, rather than squashing the tabs.

See also

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

Examples

ui <- shinyGovstyle::gov_page(
  shinyGovstyle::header(
    org_name = "Example",
    service_name = "User Examples",
    logo = "shinyGovstyle/images/moj_logo.png",
    logo_alt_text = "Ministry of Justice logo"
  ),
  shinyGovstyle::gov_main_layout(
    shinyGovstyle::govTabs("tabs", shinyGovstyle::case_data, "tabs")
  ),
  shinyGovstyle::footer(full = TRUE)
)

server <- function(input, output, session) {}
if (interactive()) shinyApp(ui = ui, server = server)