Skip to main content

Form label

The Label component renders a Bootstrap-styled form label and associates it with a form control using the htmlFor prop.

Import​

import { Form } from "@promethey/bsui";

Note

Label inherits all utility props supported by the Prime component, including spacing, typography, colors, positioning, and other Bootstrap utility APIs.

Basic usage​

Use htmlFor to associate the label with a form control. The value must match the id of the corresponding control.

Clicking the label focuses the associated control.

Form example​

Label can be used together with other BSUI form components to build consistent forms.

Required field​

Label does not provide validation behavior itself, but its content can include additional elements such as a required indicator.

Utility props​

Label inherits all utility props provided by Prime.

API​

Label​

PropTypeDefaultDescription
childrenReactNode—Label content.
htmlForstring—Associates the label with a form control by its id.
classNamestring | objectnullAdditional class names applied to the label.
styleobjectnullInline styles applied to the label.

Label also supports all props provided by Prime.

Accessibility​

Always provide an htmlFor value that matches the id of the associated form control:

<Label htmlFor="email">Email</Label>
<Control id="email" type="email" />

This creates the native HTML association between the label and the control, allowing users to activate or focus the control by interacting with its label.