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.
children
The label text that appears above the form element.
React.ReactNode
null
for
id
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.
string
isDisabled
Visually disable the label.
boolean
false
hasError
Changes the label text color to red.
boolean
false
dataTestId
A selector to hook into the React component for use in automated testing environments.
string
dataTest
A selector to hook into the React component for use in automated testing environments.
Note: Deprecated in favor of the `dataTestId` prop
string