File: label.md | Updated: 11/15/2025
ThemesThemes PrimitivesPrimitives IconsIcons ColorsColors
Documentation Case studies Blog
Search
/
Introduction Getting started Accessibility Releases
Styling Animation Composition Server-side rendering
Accordion
Alert Dialog
Aspect Ratio
Avatar
Checkbox
Collapsible
Context Menu
Dialog
Dropdown Menu
Form
Preview
Hover Card
Label
Menubar
Navigation Menu
One-Time Password Field
Preview
Password Toggle Field
Preview
Popover
Progress
Radio Group
Scroll Area
Select
Separator
Slider
Switch
Tabs
Toast
Toggle
Toggle Group
Toolbar
Tooltip
Accessible Icon Direction Provider Portal Slot Visually Hidden
Components
Renders an accessible label associated with controls.
First name
index.jsxindex.jsxstyles.cssstyles.css
CSS
import * as React from "react";
import { Label } from "radix-ui";
import "./styles.css";
const LabelDemo = () => (
<div
style={{
display: "flex",
padding: "0 20px",
flexWrap: "wrap",
gap: 15,
alignItems: "center",
}}
>
<Label.Root className="LabelRoot" htmlFor="firstName">
First name
</Label.Root>
<input
className="Input"
type="text"
id="firstName"
defaultValue="Pedro Duarte"
/>
</div>
);
export default LabelDemo;
Text selection is prevented when double clicking label.
Supports nested controls.
Install the component from your command line.
npm install @radix-ui/react-label
Import the component.
import { Label } from "radix-ui";
export default () => <Label.Root />;
Contains the content for the label.
| Prop | Type | Default |
| --- | --- | --- |
| asChild<br><br>Prop description | boolean | false |
| htmlFor<br><br>Prop description | string | No default value |
This component is based on the native label element, it will automatically apply the correct labelling when wrapping controls or using the htmlFor attribute. For your own custom controls to work correctly, ensure they use native elements such as button or input as a base.
PreviousHover Card
NextMenubar