Skip to main content
HomeFormForm Label
warning
This is a beta release of the Quantum web libraries
Please be careful when using them in production, as they may contain bugs, unstable breaking changes, and incomplete features.

Form Label

FormLabel element need to describe the purpose of the form field. Whenever possible, use the label element to associate text with form elements explicitly.

<FormLabel><span>Form Label</span></FormLabel>

for attribute

The for attribute specifies the ID of the element that the label is associated with.

React replaces the for attribute with htmlFor to avoid conflicts and ensure compatibility with JavaScript.

<FormLabel htmlFor="text-input-id"><span>Email</span></FormLabel>
<TextInput
inputProps={{
id: "text-input-id",
placeholder: "Enter email"
}}
/>

Sizes

Control the size of a form label setting size attribute to small, medium or large value. By default, the label has size medium.

<FormLabel size="small"><span>Form Label Small</span></FormLabel>
<FormLabel size="medium"><span>Form Label Medium</span></FormLabel>
<FormLabel size="large"><span>Form Label Large</span></FormLabel>

Required

Add required attribute in form label to put a red required asterisk to the first child of label to indicate that the field is required.

<FormLabel required><span>Form Label</span></FormLabel>

Disabled

Add disabled attribute in form label to disable the element.

<FormLabel disabled><span>Form Label</span></FormLabel>

API

The FormLabel component accepts all the props a standard <label> does in React (HTML, ARIA, data attributes, event handlers, and children). Its props are typed as React.LabelHTMLAttributes<HTMLLabelElement>. See more about supported HTML props in React's documentation.

Loading API documentation...

Spotted a bug, have a question, or want to suggest a new feature?

Submit an issue on GitLab