suiss/ui · Component
Label
An accessible text label that names a form control.
Label is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Label renders a native label element with the library's form typography. Associate it with a control through htmlFor, or nest the control inside it, so clicking the label focuses or toggles the control.
Use Label for standalone controls. Inside a Field layout, prefer the field's own label part when one is provided.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
-
Add the
cnhelper. -
Copy the source into
components/ui/label.tsx:
- Update the import paths to match your project.
Usage
Give the control an id and pass the same value to htmlFor. Next to a checkbox, radio item or switch, the label automatically switches to regular weight.
Examples
With input
A label linked to a text input; clicking the label focuses the input.
With checkbox
A label placed after a checkbox; clicking the label toggles it.
Disabled
A label shown in its dimmed style inside a disabled group, above a disabled input.
API Reference
Label
Renders a label element that names and activates its associated control.
Also accepts the props of React.ComponentProps<"label">.
Accessibility
- The label text becomes the control's accessible name when linked with
htmlForor by nesting. - Clicking the label focuses a text input or toggles a checkbox, matching native
labelbehavior.
Notes
- Styling hook:
data-slot="label". - The label dims to
opacity-50when it follows a disabled peer control, or when an ancestor with thegroupclass hasdata-disabled="true". - Font weight drops to normal when the label contains, or follows, a
checkbox,radio-group-itemorswitchslot.

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 is dimmed to 50% opacity.
Installation
Manual
- Install the dependencies:
-
Add the pieces it builds on: the primitives
components/primitives/label.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/label.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: the primitives
components/primitives/label.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/label.tsx:
- Update the import paths to match your project.
-
Add the pieces it builds on: the primitives
components/primitives/label.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/label.tsx:
- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
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.

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

Disabled
A disabled label.

API Reference
Label
Also accepts the props of React.ComponentProps<typeof LabelPrimitive.Text>.
Accessibility
- The label text reports its
disabledstate inaccessibilityState. - Link it to its control with
nativeIDon the label andaccessibilityLabelledByon the control.
Notes
- Text uses the
text-foregroundtoken, andopacity-50when disabled. - Light and dark colors follow the system appearance.



