ZUI

Search documentation

Find a page or a heading.

Icon label

A label whose icon stands in for a field's text in a dense panel, named for a screen reader by its aria-label, tied to its input through nativeID and sizing an Icon with no size of its own to a compact glyph.

Installation

bash

The CLI writes components/general/icon-label.tsx, installs Icon, Text and Utils, and adds @rn-primitives/label.

Usage

tsx
tsx

Use it to stand in for a field's own text label in a dense panel. Compose a Tooltip around it, with asChild on the trigger, to show the words when it is pressed; it then opens the tooltip rather than focusing the input. For a glyph that carries no field of its own, such as a model ability, use Icon media instead.

API reference

IconLabel

Takes every prop of @rn-primitives/label's Root, a Pressable, plus:

aria-label holds the words the icon stands in for, which a screen reader reads. An input that names nativeID in aria-labelledby takes the label's name on Android; iOS does not read aria-labelledby, so give the input the same words in its own aria-label. Pressing the label runs its onPress, which you point at the input's focus(). An Icon inside it with no size-* class of its own is drawn at size-3, in the muted foreground.

Differences from the web

  • The web's htmlFor is dropped: React Native has no label-to-input link, so nativeID and onPress stand in for it, as on Label.
  • The web's visually hidden sr-only text is dropped, since a device has no such class; the words go in the required aria-label.