Accessible wrappers for popular R Shiny UI components, enforcing ARIA attributes and structural requirements in line with BITV 2.0 and WCAG 2.1 AA.
Install the package directly from GitLab:
install.packages("devtools")
devtools::install_git("https://gitlab.opencode.de/bmbf/datenlabor/barrierefrei-r.git")
Alternatively, clone the repository and use renv for reproducible dependency management:
# Set your working directory to the package root
setwd("path/to/barrierefrei-r")
renv::init()
renv::install(".")
renv::snapshot()
Load the package and replace standard Shiny UI functions with their accessible counterparts:
library(a11yShiny)
ui <- a11y_fluidPage(
lang = "de",
title = "Accessible Demo",
a11y_fluidRow(
a11y_column(6, a11y_actionButton("go", label = "Go!")),
a11y_column(6, a11y_selectInput("sel", label = "Choose", choices = 1:3))
)
)
For accessible DataTables and basic line/bar charts:
output$tbl <- a11y_renderDataTable({ head(iris, 10) }, lang = "de")
output$plt <- renderPlotly({
p <- a11y_ggplot2_line(data = iris, x = ~Species, y = ~Sepal.Length)
plotly::ggplotly(p)
})
A full demo app is included in the package:
shiny::runApp(system.file("examples", "demo", "app.R", package = "a11yShiny"))
For detailed documentation on each function, see the package reference (?a11y_fluidPage, ?a11y_actionButton, etc.) and the examples in inst/examples/.
Wrappers for fluidPage(), fluidRow() and column().
<title> title, <lang> language, and unique <main> landmark..a11y-flow, .a11y-row, .a11y-col and optional header/nav/footer.column() function).<h1>, <h2>, ...) is not enforced. No validation of meanigful (ARIA) text label (9.2.4.6). If nested fluidRows are used seamless keyboard navigation is not guaranteed (9.2.1.1)Wrapper for actionButton().
.a11y-btn.Wrapper for selectInput(), numericInput(), textInput(), dateInput() and radioButtons().
<h1>-<h6>)..a11y-sr-only)..a11y-select, .a11y-numeric, .a11y-text, .a11y-date and .a11y-radio.Composite wrapper combining a labeled text input and an action button (e. g. for a search bar with button).
a11y_textInput() and a11y_actionButton() with their validations and CSS focus styling.aria-controls to the button, by default pointing to the text input ID (configurable), so assistive technologies understand which control is affected by the button..a11y-sr-only)..a11y-text-action-group and modifier classes.Wrapper for a group of related textInput elements inside a <fieldset> with <legend> (e.g. address fields, date components, grouped inputs).
<fieldset> with a visible <legend> as group label and marks it with role="group" and aria-labelledby to the legend.<h1>-<h6>)..a11y-sr-only)..a11y-text.Wrapper for renderDataTable().
.a11y-dt: To enable CSS style, wrap dataTableOutput() in a div with a custom class, e.g.:div(class = "a11y-dt", DT::dataTableOutput("mytable"))
A generic wrapper for ggplot2/ggplotly charts is not recommended due to low flexibility and high risk of errors. Several approaches for accessible diagram wrappers were evaluated, but due to limitations, only the first option was implemented in this package as a minimal example:
a11y_ggplot2_bar/line).
Limitation: Must be created for every chart type; user modifications after the wrapper can impair accessibility.Support for pattern fills, certain ARIA attributes, or colorblind-friendly mapping is always limited by ggplot2/plotly's underlying capabilities and design. Instead users should follow accessibility guidelines for charts. Best practice: Users should
Minimal wrapper for ggplot2() for a multi-line and simple bar chart.
inst/examples/demo/app.R).Wrapper for a global high-contrast mode toggle button.
high-contrast class on the <body> element: All standard Shiny buttons, form controls and dataTable controls switch to a high-contrast style (inverted colors, clear borders and focus outline)aria-pressed="true"/"false" on the button so screen readers can understand the toggle state.a11y_actionButton() and inherits its validation..a11y-high-contrast-toggle that the JS and CSS high-contrast styling are attached to.Limitations are mainly library-dependent. Some specific capabilities (modal copy dialogs, responsive DT layouts, numeric DT filters, chart tooltips) cannot yet be made fully accessible through wrappers alone. Always test your outputs with accessibility auditing tools (see below).
Contributions to a11yShiny are welcome. Please open an issue or submit a merge request on the GitLab repository.
a11yShiny is licensed under the European Union Public Licence (EUPL) v1.2.
a11yShiny requires R >= 4.1.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.