a11y_radioButtons: Accessible radio buttons

View source: R/inputs.R

a11y_radioButtonsR Documentation

Accessible radio buttons

Description

A wrapper for shiny::radioButtons() with ARIA attributes according to BITV 2.0, enforced visible label, optional heading annotation, custom CSS class, and sr-only description support.

Usage

a11y_radioButtons(
  inputId,
  label,
  choices,
  selected = NULL,
  inline = FALSE,
  ...,
  describedby = NULL,
  describedby_text = NULL,
  heading_level = NULL,
  aria_controls = NULL
)

Arguments

inputId

Input ID

label

Visible label (required)

choices

Choices (as in shiny::radioButtons())

selected

Preselected value (optional)

inline

Display inline (logical, default: FALSE)

...

Additional arguments for shiny::radioButtons()

describedby

ID of an element for aria-describedby (optional)

describedby_text

Creates an sr-only ⁠<div>⁠ that serves as a description and is linked via aria-describedby. If describedby is set, its ID is used, otherwise an ID is generated (⁠<inputId>-desc⁠). (optional)

heading_level

1–6, marks the visible ⁠<label>⁠ as a heading via role="heading" and aria-level (optional)

aria_controls

(optional) ARIA controls attribute

Value

HTML tag of the input component (possibly with sr-only description)

Examples

# Basic radio buttons
a11y_radioButtons("format", "Output format",
  choices = c("CSV", "Excel", "JSON")
)

# Inline layout with heading annotation
a11y_radioButtons("yesno", "Agree?",
  choices = c("Yes", "No"),
  inline = TRUE,
  heading_level = 4
)

# With named choices and a screen-reader description
a11y_radioButtons("radio_choice", "Pick one",
  choices = list(
    "Option 1" = 1,
    "Option 2" = 2,
    "Option 3" = 3
  ),
  selected = 1,
  describedby_text = "Select one of the three options"
)


a11yShiny documentation built on April 1, 2026, 5:07 p.m.