- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
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#
pnpm dlx shadcn@latest add @zui/icon-labelThe CLI writes components/general/icon-label.tsx, installs Icon,
Text and Utils, and adds @rn-primitives/label.
Usage#
import { IconLabel } from '@/components/general/icon-label';const input = useRef<TextInputInstance>(null);
<IconLabel aria-label="Filter" nativeID="filter" onPress={() => input.current?.focus()}>
<Icon as={Search} />
</IconLabel>
<Input ref={input} aria-label="Filter" aria-labelledby="filter" placeholder="Filter..." />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:
| Prop | Type | Default |
|---|---|---|
aria-label | string | required |
nativeID | string | - |
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
htmlForis dropped: React Native has no label-to-input link, sonativeIDandonPressstand in for it, as on Label. - The web's visually hidden
sr-onlytext is dropped, since a device has no such class; the words go in the requiredaria-label.