Skip to content
Docs

Label

Renders an accessible label associated with controls.

Renders an accessible label associated with controls.

<div style="display: flex; padding: 0 20px; flex-wrap: wrap; gap: 15px; align-items: center;">
  <Label.label class="DemoLabelRoot" for="firstName">
    First Name
  </Label.label>
  <input class="DemoInput" type="text" id="firstName" value="Pedro Duarte" />
</div>
Text selection is prevented when double clicking label.
Supports nested controls.

Anatomy

Import the component.

<Label.label />

Anatomy

Label
Contains the content for the label.

API Reference

Label

Contains the content for the label. Use for to associate with a control.

Prop Type Default Description
for string
for
Type string Default

Accessibility

This component is based on the native label element. It applies the correct labelling when wrapping controls or using the for attribute. For custom controls to work correctly, ensure they use native elements such as button or input as a base.