Components
Form labels commonly used with inputs.
| Version: | 14.18.2 •View source•Changelog•Report issue | |
|---|---|---|
| Install: | yarn add @thumbtack/thumbprint-react | |
| Import: | import { Label } from '@thumbtack/thumbprint-react'; | |
The Label React component uses the for prop to associate itself with a form field.
The for and id props must match and be unique to the page. You can use Lodash’s uniqueId to generate a unique id.
Labels can appear visually disabled. It’s important to also disable the associated form element.
You can change the label color to red when the associated form element has invalid data.
Validation errors must be also include text that explains the error. This helps guide the user and is crucial for users with visual impairments.
childrenThe label text that appears above the form element.
React.ReactNodenullforid of the form field that’s associated with the label. Clicking on the label text will
switch the browser’s focus to the form field.
The Label’s for and form field’s id prop must match and be unique to the page. You can
use Lodash’s uniqueId to generate a unique id.
stringisDisabledVisually disable the label.
booleanfalsehasErrorChanges the label text color to red.
booleanfalsedataTestIdA selector to hook into the React component for use in automated testing environments.
stringdataTestA selector to hook into the React component for use in automated testing environments.
Note: Deprecated in favor of the `dataTestId` prop
string