Skip to content

Label Primitive

Slot Primitives

Types Primitives

@radix-ui/react-label


A user-friendly label linked to controls for improved accessibility.

Installation

Install @radix-ui/react-label

Terminal window
npx expo install @radix-ui/react-label

Copy/paste the following code for web to ~/components/primitives/label/label.web.tsx

Copy/paste the following code for native to ~/components/primitives/label/label.tsx

Copy/paste the following code for types to ~/components/primitives/label/types.ts

Copy/paste the following code for exporting to ~/components/primitives/label/index.ts

Usage

import * as LabelPrimitive from '~/components/primitives/label';
function Example() {
const [checked, setChecked] = React.useState(false);
return (
<Label.Root>
<Label.Text
nativeID='to-be-use-by-aria-labelledby-from-form-field'
>
Label
</Label.Text>
</Label.Root>
);
}

Props

Root

Extends Pressable props except children | hitSlop | style

PropTypeNote
children*React.ReactNode
styleViewStyle(optional)

Text

Extends Text props

PropTypeNote
nativeID*stringthe same value needs be use by aria-labelledby from form field