- Docs
- Components
- 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
// 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.
| Prop | Type | Default | What it does |
|---|---|---|---|
label | ReactNode | required | The label. A placeholder is never a label. |
description | ReactNode | — | Help under the box: a format, a limit. Hidden while an error shows. |
error | ReactNode | — | An error to show now, e.g. from the server; it marks it invalid. |
optional | boolean | false | Appends "(optional)". Required fields aren't marked. |
help | ReactNode | — | An explanation behind ⓘ, after the label. |
hideLabel | boolean | false | Hides the label but keeps it for screen readers: a toolbar search only. |
icon | IconSource | — | A leading icon, 16px and decorative. |
startAdornment | ReactNode | — | Before the value: ₹. |
endAdornment | ReactNode | — | 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 · onValueChange | string | — | 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-slot | Element | What 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.
<TextField
label="Work email"
type="email"
name="email"
validationMode="onBlur"
validate={(value) => (String(value).endsWith("@acme.in") ? null : "Use your acme.in email.")}
/>