Interface HasAriaDescription

All Superinterfaces:
HasElement, Serializable
All Known Implementing Classes:
AbstractNumberField, BigDecimalField, Checkbox, CheckboxGroup, ComboBox, ComboBoxBase, DatePicker, DecimalSlider, EmailField, IntegerField, IntegerSlider, MultiSelectComboBox, NumberField, PasswordField, RadioButtonGroup, Select, Switch, TextArea, TextField, TextFieldBase, TimePicker

public interface HasAriaDescription extends HasElement
A generic interface for components that have an accessible description.

The accessible description provides supplementary information about the component to assistive technologies, such as screen readers. It is set by referencing existing elements on the page with the aria-describedby attribute.

Since:
25.3
Author:
Vaadin Ltd
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Optional<String>
    Gets the aria-describedby attribute of the component.
    default void
    setAriaDescribedBy(Component descriptionComponent)
    Sets the aria-describedby attribute of the component to reference the given description component.
    default void
    setAriaDescribedBy(String ariaDescribedBy)
    Sets the aria-describedby attribute of the component to one or more element IDs, separated by spaces.

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement
  • Method Details

    • setAriaDescribedBy

      default void setAriaDescribedBy(String ariaDescribedBy)
      Sets the aria-describedby attribute of the component to one or more element IDs, separated by spaces.

      Each ID must match the id attribute of another element that describes the component. The description elements must be in the same DOM scope as the component, otherwise screen readers will fail to announce the description content properly.

      Parameters:
      ariaDescribedBy - a space-separated list of element IDs, or null to remove the attribute
      See Also:
    • setAriaDescribedBy

      default void setAriaDescribedBy(Component descriptionComponent)
      Sets the aria-describedby attribute of the component to reference the given description component.

      The description component does not need an ID: if it has none by the time the value is sent to the client, one is generated automatically. The attribute value is available right away, but a generated ID is only assigned to the description component before the next client response after this component is attached, so the value read with getAriaDescribedBy() should not be cached within the same request.

      Calling setAriaDescribedBy(String), also with null to remove the attribute, or referencing another component cancels a pending resolution, leaving the previously referenced component's ID untouched.

      The description component must be in the same DOM scope as this component, otherwise screen readers will fail to announce the description content properly.

      Parameters:
      descriptionComponent - the component to use as the description, not null
      Throws:
      IllegalArgumentException - if descriptionComponent is null; use setAriaDescribedBy(String) with null to remove the attribute instead
      See Also:
    • getAriaDescribedBy

      default Optional<String> getAriaDescribedBy()
      Gets the aria-describedby attribute of the component.
      Returns:
      an optional aria-describedby, or an empty optional if none has been set