Interface HasAriaLabel

  • All Superinterfaces:
    HasElement, Serializable
    All Known Implementing Classes:
    Anchor, Image, Input, Main, NativeButton, Nav

    public interface HasAriaLabel
    extends HasElement
    A generic interface for components and other user interface objects that may have an aria-label property to set the accessible name of the component.

    The default implementations set the aria-label of the component to the given HasElement.getElement(). Override all methods in this interface if the aria-label should be added to some other element.

    The purpose of aria-label is to provide the user with a recognizable name of the component. If the label text is visible on screen, aria-label should not be used. There may be instances where the name of an element cannot be determined programmatically from the content of the element, and there are cases where providing a visible label is not the desired user experience. In the cases where a visible label or visible tooltip is undesirable, aria-label may be used to set the accessible name of the component.

    See: https://www.w3.org/TR/wai-aria/#aria-label

    Note: The aria-label property is not valid on every component, see https://www.w3.org/TR/using-aria/#label-support for more details.

    Since:
    Author:
    Vaadin Ltd
    • Method Detail

      • setAriaLabel

        default void setAriaLabel​(String ariaLabel)
        Set the aria-label of the component to the given text.
        Parameters:
        ariaLabel - the aria-label text to set or null to clear
      • getAriaLabel

        default Optional<String> getAriaLabel()
        Gets the aria-label of the component.
        Returns:
        an optional aria-label of the component if no aria-label has been set