Label
An accessible label component for Base UI form controls.
View as MarkdownUsage guidelines
- Use when standalone:
Labelis a lightweight version of Field.Label that does not include Field validation state attributes. Use Field.Label when the control is wrapped in Field.Root. - Use non-native labeling for trigger controls: For controls like
<Select.Trigger>and<Combobox.Trigger>, setnativeLabel={false}andrender={<div />}so clicks focus the trigger without inheriting native<label>behavior.
Anatomy
Import the component and use it as a single part:
import { Label } from '@base-ui/react/label';
<Label>Label</Label>Labeling patterns
For <Checkbox.Root>, <Switch.Root>, and <Radio.Root>, prefer wrapping the control with Label instead of using a sibling label. Wrapping avoids tracking IDs manually and keeps CSS gaps between the control and text clickable.
<Label>
<Checkbox.Root />
Enable notifications
</Label>Sibling htmlFor/id labeling is supported as a fallback. For non-nativeButton controls, aria-labelledby is attached after hydration. If you need sibling labeling behavior during SSR, use nativeButton with render={<button />} on the control.
const id = React.useId();
<Label htmlFor={id}>Enable notifications</Label>
<Checkbox.Root id={id} nativeButton render={<button />} />Label also prevents accidental text selection from double clicks on the label.
Examples
Labeling a checkbox
<Label>
<Checkbox.Root />
Enable notifications
</Label>Labeling a select trigger
<Select.Root>
<Label nativeLabel={false} render={<div />}>
Theme
<Select.Trigger>{/* ... */}</Select.Trigger>
</Label>
<Select.Portal>{/* ... */}</Select.Portal>
</Select.Root>API reference
nativeLabelbooleantrue
- Name
- Description
Whether the component renders a native
<label>element when replacing it via therenderprop. Set tofalseif the rendered element is not a label (e.g.<div>).This is useful to avoid inheriting label behaviors on
<button>controls (such as<Select.Trigger>and<Combobox.Trigger>), including avoiding:hoveron the button when hovering the label, and preventing clicks on the label from firing on the button.- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Label.State) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | ((state: Label.State) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | ((props: HTMLProps, state: Label.State) => ReactElement)