Skip to main content
  1. Docs
  2. Components
  3. Forms

Text field

A labelled text input: the default form row. A label always; a placeholder is only an example.

Import
@qeetrix/react
Status
StableSince 0.0.2
Renders
<input>Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

text-field.tsx
// From the package: a build keeps only what it uses.
import { TextField } from "@qeetrix/react";

// Or from its own path.
import { TextField } from "@qeetrix/react/text-field";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
labelReactNoderequiredThe label. A placeholder is never a label.
descriptionReactNode—Help under the box: a format, a limit. Hidden while an error shows.
errorReactNode—An error to show now, e.g. from the server; it marks it invalid.
optionalbooleanfalseAppends "(optional)". Required fields aren't marked.
helpReactNode—An explanation behind ⓘ, after the label.
hideLabelbooleanfalseHides the label but keeps it for screen readers: a toolbar search only.
iconIconSource—A leading icon, 16px and decorative.
startAdornmentReactNode—Before the value: ₹.
endAdornmentReactNode—After the value: %, .qeet.in, or a tool.
validate(value, formValues) => string | null—Your own check: return the error, or null.
validationMode"onSubmit" | "onBlur" | "onChange""onSubmit"When it checks.
value · defaultValue · onValueChangestring—Controlled or not, as an input.
type · required · disabled · readOnly · name…—As on an <input>: disabled and name go to the field.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
text-field<div>The row: label, box, description.
field-label<label>The label; field-optional holds "(optional)".
input<div>The box, with input-icon, input-start and input-end.
input-control<input>The input: ref and native props land here.
field-description<p>The help line.
field-error<div>The error, in its place.

04

Check as you leave it

validate returns the error; onBlur says it once the person moves on.

work-email.tsx
<TextField
  label="Work email"
  type="email"
  name="email"
  validationMode="onBlur"
  validate={(value) => (String(value).endsWith("@acme.in") ? null : "Use your acme.in email.")}
/>
Next — Text fieldAccessibility