Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Semantics

    A label for the screen reader (VoiceOver, TalkBack, browser screen readers): what the element is called, what it is — a button, a heading, a link, an image — and what state it is in. It does not affect the look.

    Needed where the meaning is not visible from the text: an icon without a caption, an image, a block assembled from several Text elements, a tappable card.

    Type: single-child

    Semantics label:"Cart, 3 items" button:true
      Icon shopping_cart

    Parameters

    Parameter Type Default Description
    label string — What it is, in words: “Close”, “Profile photo”
    hint string — What happens on action: “Opens the profile”
    value string — The current value: “3”, “50 %”
    button bool — It is a button
    link bool — It is a link
    header bool — It is a section heading
    image bool — It is an image
    textField bool — It is a text field
    enabled bool — Whether the element is available; false — the screen reader says “unavailable”
    checked bool — Whether it is checked (for checkboxes and switches)
    selected bool — Whether it is selected (a tab, an option)
    readOnly bool — A read-only field
    focusable bool — Whether it can receive screen reader focus
    focused bool — Whether it is focused now
    hidden bool — Whether it is hidden (not on screen now)
    excludeSemantics bool false Do not read what is inside: the screen reader hears only this element's label
    container bool false Read the element as a separate node instead of merging it with its neighbours

    Flags that are not set assert nothing: checked without a value means “there is no checkbox”, not “unchecked”.

    Examples

    Icon button

    @open:false
    Semantics label:"Menu" button:true
      IconButton onPressed:{open = true}
        Icon menu

    Section heading

    Semantics header:true
      Text "Pricing"
        #style fontSize:24 fontWeight:bold

    A block of several lines as one phrase

    Semantics label:"Rating 4.8 out of 5, 120 reviews" excludeSemantics:true
      Row spacing:4
        Icon star color:0xFFF59E0B
        Text "4.8"
        Text "(120)"

    Without excludeSemantics the screen reader would read “star”, “4.8”, “(120)” separately.

    Differences between the app and the site

    On the site Semantics adds no wrapper: the ARIA attributes go straight onto the child's element.

    Parameter On the site
    label aria-label ; on a text field — on the field itself
    value aria-valuetext
    button , link , header , image , textField role : button , link , heading , img , textbox — the first one set, in this order, is taken
    checked , selected , readOnly aria-checked , aria-selected , aria-readonly
    enabled:false aria-disabled="true"
    hint , focusable , focused , hidden , excludeSemantics , container not read

    Consequences for the site: hidden:true does not hide the element from the screen reader, and excludeSemantics:true does not mute the children — the reader reads both the aria-label and the text inside as it sees fit. A heading gets role="heading" without a level.

    Best practices

    • Label what cannot be read. An icon without text and an image need a label ; a button with a caption does not: the caption is its name.
    • Do not duplicate visible text in label — the screen reader will read it twice.
    • One role. If you need both button and link , pick the one that describes the action: navigation is a link, an action in place is a button.

    See also

    • Icon — an icon, which usually needs a label
    • Image — an image
    • InkWell — a tappable block (on the site it gets the button role by itself)
    • Focus and keyboard — working without a mouse