Skip to content

Text field

Design guidelines
HTML
React
Angular
<certara-input placeholder="Placeholder" />
import { CertaraInput } from '@certara/certara-ui-react';
<CertaraInput placeholder="Placeholder" />
// In your module (e.g., app.module.ts)
import { CertaraUiAngularModule } from '@certara/certara-ui-angular';
@NgModule({
imports: [CertaraUiAngularModule]
})
// In your template:
<certara-input placeholder="Placeholder"></certara-input>
HTML
React
Angular
Help or instructional text goes here
<certara-form-group label="Label" layout="stacked">
<span slot="help">Help or instructional text goes here</span>
<certara-input placeholder="Placeholder"></certara-input>
</certara-form-group>
import { CertaraFormGroup, CertaraInput } from '@certara/certara-ui-react';
<CertaraFormGroup label="Label" layout="stacked">
<span slot="help">Help or instructional text goes here</span>
<CertaraInput placeholder="Placeholder" />
</CertaraFormGroup>
// In your module (e.g., app.module.ts)
import { CertaraUiAngularModule } from '@certara/certara-ui-angular';
@NgModule({
imports: [CertaraUiAngularModule]
})
// In your template:
<certara-form-group label="Label" layout="stacked">
<span slot="help">Help or instructional text goes here</span>
<certara-input placeholder="Placeholder"></certara-input>
</certara-form-group>
HTML
React
Angular
<certara-input type="text" placeholder="Text input" />
import { CertaraInput } from '@certara/certara-ui-react';
<CertaraInput type="text" placeholder="Text input" />
// In your module (e.g., app.module.ts)
import { CertaraUiAngularModule } from '@certara/certara-ui-angular';
@NgModule({
imports: [CertaraUiAngularModule]
})
// In your template:
<certara-input type="text" placeholder="Text input"></certara-input>
HTML
React
Angular
<certara-input placeholder="Medium (default)" />
import { CertaraInput } from '@certara/certara-ui-react';
<CertaraInput placeholder="Medium (default)" />
// In your module (e.g., app.module.ts)
import { CertaraUiAngularModule } from '@certara/certara-ui-angular';
@NgModule({
imports: [CertaraUiAngularModule]
})
// In your template:
<certara-input placeholder="Medium (default)"></certara-input>

Single-line text input. Pair with <certara-form-group> for labelling.

accept

Attributeaccept
Typestring
Defaultundefined
Requiredfalse
DescriptionAccepted file types for file inputs (e.g., “.pdf,.doc”).

disabled

Attributedisabled
Typeboolean
Defaultfalse
Requiredfalse
DescriptionPrevents user interaction.

max

Attributemax
Typenumber | string
Defaultundefined
Requiredfalse
DescriptionMaximum value for number/date inputs.

maxlength

Attributemaxlength
Typenumber
Defaultundefined
Requiredfalse
DescriptionMaximum number of characters allowed.

min

Attributemin
Typenumber | string
Defaultundefined
Requiredfalse
DescriptionMinimum value for number/date inputs.

minlength

Attributeminlength
Typenumber
Defaultundefined
Requiredfalse
DescriptionMinimum number of characters required.

name

Attributename
Typestring
Defaultthis.inputId
Requiredfalse
DescriptionForm control name, used for form submission and validation events.

pattern

Attributepattern
Typestring
Defaultundefined
Requiredfalse
DescriptionRegex pattern the value must match.

placeholder

Attributeplaceholder
Typestring
Defaultundefined
Requiredfalse
DescriptionPlaceholder text shown when empty.

readonly

Attributereadonly
Typeboolean
Defaultfalse
Requiredfalse
DescriptionPrevents editing while allowing selection and copy.

required

Attributerequired
Typeboolean
Defaultfalse
Requiredfalse
DescriptionMarks the field as required for form validation.

size

Attributesize
Type"md" | "sm"
Default'md'
Requiredfalse
DescriptionVisual size variant of the input.

step

Attributestep
Typenumber | string
Defaultundefined
Requiredfalse
DescriptionStep increment for number inputs.

type

Attributetype
Type"date" | "datetime-local" | "email" | "file" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url"
Default'text'
Requiredfalse
DescriptionInput type, affects keyboard on mobile and validation.

value

Attributevalue
Typestring
Defaultundefined
Requiredfalse
DescriptionCurrent value of the input.
NameDescriptionBubbles
certaraBlurEmitted when the input loses focus.true
certaraChangeEmitted when value changes from the previous value.true
certaraFocusEmitted when the input gains focus.true
certaraFormControlErrorEmitted when validation state changes. Payload is the error message or empty string when valid.true
certaraInputEmitted on every keystroke.true
NameSignatureDescription
setBlur() => Promise<void>Programmatically blurs the input.
setError(error: string) => Promise<void>Sets a custom error message. This allows consumers to call input.setError('my error message') instead of input.setAttribute('error', 'my error message').
setFocus() => Promise<void>Programmatically focuses the input.
NameDescription
appendContent placed after the input (e.g., buttons, icons).
prependContent placed before the input (e.g., labels, icons).

Text fields allow users to input custom text entries with a keyboard. Various options can be shown with the field to communicate the input requirements. Always use a label and associate the label to the field properly.

Labels can be placed either on top or on the side. Top labels are the default and are recommended because they work better with long copy, localization, and responsive layouts.

Help or instructional text goes here

Side labels are most useful when vertical space is limited.

(Required)
Help or instructional text goes here

Text fields should:

  • Be clearly labeled so it’s obvious to users what they should enter into the field
  • Be labeled as “Optional” when:
    • You need to request input that’s not required
    • And there are less optional fields than required
  • Be labeled as “Required” when:
    • You need to request input that’s required
    • And there are less required fields than optional
  • Only ask for information that’s really needed
  • For helper text provide an example or specific syntax for the input, rather than in the input area, so that it’s visible after text has been entered. Only use this where clarification is required, and try not to overuse it.
  • Field label text should be short, concise, and, when possible, in noun form. For example “Name”.
    • Edge case: When a text field isn’t part of a form and is placed individually on a page (like a comment field), then you can write the field label as a call to action. For example, “Leave a comment”. This is because there’s no surrounding context and using “Comment” alone could be confusing.

Help text provides extra guidance or instructions to people filling out a form field. It can also be used to clarify how the information will be used.

Use help text:

  • When the text field label doesn’t clearly explain the purpose of the text input
  • To provide guidance or instructions on the type of information needed
  • To show examples of the required format for modeled text inputs

Best practices:

  • Avoid repeating the field label. If the field label provides sufficient context for completing the action, then you likely don’t need to add help text.
  • If there’s not enough room to include both instructions and an example, then only include the example.
  • Screen readers convey information about text fields automatically through native HTML.
    • To disable, add the HTML disabled attribute to the text field.
    • To set as read-only, add the HTML readonly attribute to the text field.
    • Provide a unique id attribute value for the text field and use the for attribute to connect the label with the text field. This allows screen readers to convey the purpose of the text field.
  • Make sure all fields have a visible label and the label is associated properly to the field for accessibility.
  • Avoid using placeholder text whenever possible. It can pose a range of accessibility problems, like:
    • Low color contrast, making the text hard to read
    • Inconsistent behavior between browsers and screen readers
    • Text disappearing when the user starts typing, which can be confusing to people with cognitive impairments
  • Limited space available for additional context, due to field size
  • Make sure any critical information is communicated either in the field label or using helper text. Search fields or brief examples are the only exceptions where placeholder text is OK.
  • Text fields have standard keyboard support.
  • Users who rely on the keyboard expect to move focus to each text field using the tab key (or shift + tab when tabbing backwards)
  • If the type is set to number, then users can use the up and down arrow keys to adjust the value typed into the field when hovering over or focusing the field to make the arrows appear
  • The same stepping also applies to the mouse wheel while the field is focused
  • Number fields adjust by a fixed step by default; fields configured with magnitude (“log”) stepping adjust by the value’s order of magnitude instead (24 → 25, 240 → 250, 0.24 → 0.25), so steps always land on round numbers
  • Using the disabled attribute will prevent the text field from receive keyboard focus or inputs
  • The readOnly attribute allows focus on the text field but prevents input or editing
View component in Figma