a11y_highContrastButton: Accessible high-contrast toggle button

View source: R/contrast.R

a11y_highContrastButtonR Documentation

Accessible high-contrast toggle button

Description

A toggle button that switches high-contrast mode by adding/removing the CSS class .high-contrast on the ⁠<body>⁠ element, with ARIA attributes according to BITV 2.0.

Usage

a11y_highContrastButton(
  inputId = "toggle_contrast",
  label = "Contrast Mode",
  icon = shiny::icon("adjust"),
  aria_label = "Toggle high-contrast mode on or off",
  ...
)

Arguments

inputId

Button ID (default: "toggle_contrast")

label

Visible label (optional, e.g. "High Contrast")

icon

Optional icon, e.g. shiny::icon("adjust")

aria_label

ARIA label (required if label is missing/empty)

...

Additional arguments for a11y_actionButton()

Details

  • Uses a11y_actionButton() internally (visible label or aria-label).

  • Sets aria-pressed and toggles this state via JS.

  • Adds the class .a11y-high-contrast-toggle to which the JS is attached.

Value

HTML tag of the button component

Examples

# Default high-contrast toggle button
a11y_highContrastButton()

# Custom label in English
a11y_highContrastButton(
  label      = "High Contrast",
  aria_label = "Toggle high-contrast mode"
)

# Icon-only toggle (no visible label)
a11y_highContrastButton(
  label      = NULL,
  icon       = shiny::icon("adjust"),
  aria_label = "Toggle high-contrast mode"
)


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