suiss/uim · React Native Component

Label

A text label for a form control that can be pressed to act on the control.

Label is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Label on iOS in light mode

Label renders a Text inside a Pressable row. The pressable accepts onPress, onLongPress, onPressIn and onPressOut, so pressing the label can toggle or focus the control next to it. A disabled label uses a muted color.

Installation

$ pnpm dlx @esuiss/uim@latest add label

Manual

  1. Install the dependencies:
npx expo install cn
  1. Add the pieces it builds on: the primitives components/primitives/label.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/label.tsx:

uniwind/components/ui/label.tsx
import { cn } from "cn"
import * as LabelPrimitive from "@/components/primitives/label"
import { resolveClassName } from "@/components/primitives/use-render"

function Label({
  className,
  onPress,
  onLongPress,
  onPressIn,
  onPressOut,
  disabled,
  ...props
}: React.ComponentProps<typeof LabelPrimitive.Text>) {
  return (
    <LabelPrimitive.Root
      className="flex-row items-center gap-2"
  1. Update the import paths to match your project.

Usage

import { Label } from "@/components/ui/label"
<Label>Your email address</Label>

Set a nativeID on the label and point the control's accessibilityLabelledBy at it, so screen readers read the label with the control.

For a checkbox or switch, pass an onPress that toggles the control, which gives a larger touch target. Inside a Field, use FieldLabel instead.

Examples

With input

A label linked to an input through nativeID and accessibilityLabelledBy.

iOS
Label (with input) on iOS in light mode

With checkbox

A label next to a checkbox that toggles it when pressed.

iOS
Label (with checkbox) on iOS in light mode

Disabled

A disabled label.

iOS
Label (disabled) on iOS in light mode

API Reference

Label

ExtendsReact.ComponentProps<typeof LabelPrimitive.Text>

Accessibility

  • The label text reports its disabled state in accessibilityState.
  • Link it to its control with nativeID on the label and accessibilityLabelledBy on the control.

Notes

  • Text uses the text-label token, and text-label-quaternary when disabled.
  • Light and dark colors follow the system appearance.