a11y_textInputsGroup: Accessible group of text inputs

View source: R/composites.R

a11y_textInputsGroupR Documentation

Accessible group of text inputs

Description

A wrapper for a group of related text input elements inside a ⁠<fieldset>⁠/⁠<legend>⁠ with ARIA attributes according to BITV 2.0. Intended for combined form elements that belong together (e.g. address fields, date parts, etc.).

Usage

a11y_textInputsGroup(
  groupId,
  legend,
  inputs,
  describedby = NULL,
  describedby_text = NULL,
  legend_heading_level = NULL
)

Arguments

groupId

ID for the fieldset/group (used as id of ⁠<fieldset>⁠)

legend

Visible group label (used as ⁠<legend>⁠, required)

inputs

A list of input specifications. Each element must be a list with:

inputId

ID of the text input (required)

label

Visible label for this text field (optional)

value

Initial value (optional, default: "")

placeholder

Placeholder text (optional)

width

Width for this field (optional, as in shiny::textInput())

aria_label

Accessible name via aria-label (optional – required if no visible label and no title)

title

Title attribute for additional explanation or as accessible name if no visible label (optional)

describedby

ID of an element used for aria-describedby on the group (optional)

describedby_text

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

legend_heading_level

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

Details

  • The group gets a visible legend (required).

  • Each inner text input has its own ID.

  • For each inner input you must provide at least one of: a visible label, an aria_label, or a title attribute.

  • The fieldset is marked as role="group" and is linked to the legend via aria-labelledby.

Value

HTML tag of the fieldset containing multiple text inputs (possibly with an sr-only group description)

Examples

# Address field group
a11y_textInputsGroup(
    groupId = "address",
    legend = "Address",
    inputs = list(
        list(inputId = "street", label = "Street"),
        list(inputId = "city", label = "City"),
        list(inputId = "zip", label = "ZIP code")
    )
)

# With group description and legend promoted to heading level
a11y_textInputsGroup(
    groupId = "address_full",
    legend = "Postal address",
    inputs = list(
        list(inputId = "street2", label = "Street and number"),
        list(inputId = "zip2", label = "ZIP code", width = "120px"),
        list(inputId = "city2", label = "City"),
        list(inputId = "country2", label = "Country")
    ),
    describedby_text = "Please enter your full postal address.",
    legend_heading_level = 3
)


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