Maturity
Text Input Control
Text Input Field
Overview
Benefits
- 1:1 parity design/development.
- Simplified properties and usage
- On the design side, we simplified the rules and styling, all available via semantic tokens.
- On the code side, we removed properties that should belong to the parent container, hardcoded values, and magic numbers.
- Better accessibility, with holistic interaction states, colors, and more.
How to migrate
In most situations TextInputField should be a direct replacement for Input with a combined FormGroup.
// Before
<FormGroup label="First name" labelFor="signup-form-first-name">
<Input
inputRef={refs.set('firstNameInput')}
autoComplete="given-name"
type="text"
value={formData.firstName.value || ''}
onChange={formData.firstName.set}
onBlur={formData.firstName.blur}
placeholder="John"
data-e2e="signup-form-first-name"
id="signup-form-first-name"
validation={getFieldValidation('firstName')}
/>
</FormGroup>
// After
<TextInputField
label="First name"
inputRef={refs.set('firstNameInput')}
autoComplete="given-name"
type="text"
value={formData.firstName.value || ''}
onChange={formData.firstName.set}
onBlur={formData.firstName.blur}
placeholder="John"
data-e2e="signup-form-first-name"
error={formData.firstName.isErrorVisible ? formData.firstName.error : null}
/>
If previously you were using Input as a standalone control, not part of a form, use TextInputControl.
Also keep in mind TextInputField and TextInputControl can work as either a control component (you handle the state when it changes and pass the value) or has uncontrolled component (state is handled internally and you can set the defaultVaule). Pick one pattern or the other not both.
How to migrate
activeStateType
The activeStateType has been removed TextInputField and TextInputControl do not use the activeState mixin.
cornerType
The cornerType prop has been removed. As TextInputField and TextInputControl have a defined style, there is no need to keep these props around
// Before
<FormGroup label="Email" labelFor="login_email_input">
<Input
type="email"
value={formData.email.value}
onChange={formData.email.set}
placeholder="name@email.com"
id="login_email_input"
cornerType="rounded"
/>
</FormGroup>
// After
<TextInputField
label="Email"
type="email"
value={formData.email.value}
onChange={formData.email.set}
placeholder="name@email.com"
/>
id
The id prop still exists on TextInputField, but if you were previously using it to connect the FieldGroup to Input, you can remove it as TextInputField does this internally for you.
// Before
<FormGroup label="First name" labelFor="signup-form-first-name">
<Input
id="signup-form-first-name"
/>
</FormGroup>
// After
<TextInputField label="First name" />
size
The size prop has been updated as the lg has been removed and remaining values have been renamed to match a more consistent t-shirt naming pattern.
|
Before |
After |
|---|---|
|
sm |
SM |
|
m |
MD |
|
lg |
REMOVED |
validation
The validation prop has been removed as Fields and Controls no longer have warning or success statuses and instead pass the error message to the new error prop.
Any warning will end up as an error and success will be completely removed.
// Before
<FormGroup label="Name" labelFor="newName">
<Input
id="newName"
validation={errors.newName && { type: 'warning', message: errors.newName.message }}
/>
</FormGroup>
// After
<TextInputField
label="Name"
defaultValue={teamName}
readOnly={isReadOnly}
disabled={isReadOnly}
error={errors.newName?.message}
{...register('newName', { required: true })}
/>
width
The width prop has been removed as TextInputField and TextInputControl already are set to fill their entire container.
Real world examples
StepSetUp
// Before
<InputWrapper label="First line" labelFor="trm-send-email-signature-first-line">
<Input
type="text"
placeholder="e.g. {{ FirstName }} {{ LastName }}"
id="trm-send-email-signature-first-line"
onChange={handleSignatureFirstLineChange}
value={signatureFirstLine}
validation={signatureFirstLineValidation}
/>
</InputWrapper>
// After
<TextInputField
label="First line"
placeholder="e.g. {{ FirstName }} {{ LastName }}"
onChange={handleSignatureFirstLineChange}
value={signatureFirstLine}
error={signatureFirstLineValidation?.message}
/>
TeamInformationHeader
// Before
<FormGroup label="Name" labelFor="newName" labelMb="0" flex={1}>
<Input
fontSize={2}
type="text"
defaultValue={teamName}
id="newName"
readonly={isReadOnly}
validation={errors.newName && { type: 'warning', message: errors.newName.message }}
disabled={isReadOnly}
{...register('newName', { required: true })}
/>
</FormGroup>
// After
<TextInputField
label="Name"
defaultValue={teamName}
readOnly={isReadOnly}
disabled={isReadOnly}
error={errors.newName?.message}
{...register('newName', { required: true })}
/>