Nothing
#' Accessible high-contrast toggle button
#'
#' 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.
#'
#' - 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.
#'
#' @param inputId Button ID (default: `"toggle_contrast"`)
#' @param label Visible label (optional, e.g. `"High Contrast"`)
#' @param icon Optional icon, e.g. `shiny::icon("adjust")`
#' @param aria_label ARIA label (required if `label` is missing/empty)
#' @param ... Additional arguments for [a11y_actionButton()]
#'
#' @return 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"
#' )
#'
#' @export
a11y_highContrastButton <- function(
inputId = "toggle_contrast",
label = "Contrast Mode",
icon = shiny::icon("adjust"),
aria_label = "Toggle high-contrast mode on or off",
...
) {
# Base: a11y_actionButton
btn <- a11y_actionButton(
inputId = inputId,
label = label,
icon = icon,
aria_label = aria_label,
...
)
# Add aria-pressed
btn <- add_aria(btn, pressed = "false")
# Add class for JS
btn <- htmltools::tagAppendAttributes(
btn,
class = "a11y-high-contrast-toggle"
)
# Attach JS/CSS dependency
htmltools::attachDependencies(btn, list(use_a11y()))
}
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.