qat

Text fields

Field, TextField, TextArea, NumberField, PasswordField, SearchField. They are copied into your app’s ui/ by qatjs add input: the code is yours to edit.

Example

We only use it for the receipt.
That address has no @. Enter one like name@example.az.
₼per kg
44 / 200
kg
Fair. Add a number or a symbol.
Example.qx33 lines, 1 reactive nameOpen in the playground
import { NumberField, PasswordField, SearchField, TextArea, TextField } from './ui/input/input.qx'

export default function Example() {
  let email = state('')
  return (
    <div class="example-grid">
      <TextField
        label="Email"
        type="email"
        required
        help="We only use it for the receipt."
        placeholder="name@example.az"
        bind:value={email}
      />
      <TextField
        label="Email"
        error="That address has no @. Enter one like name@example.az."
        value="leyla.example.az"
      />
      <TextField label="Price" prefix="₼" suffix="per kg" value="84.00" />
      <TextArea label="Note to the courier" maxLength={200} value="Qapı zəngi işləmir, zəhmət olmasa zəng edin." />
      <NumberField label="Weight" unit="kg" step={0.1} value={2.4} />
      <PasswordField
        label="New password"
        value="correcthorse"
        strength={2}
        strengthText="Fair. Add a number or a symbol."
        autocomplete="new-password"
      />
      <SearchField label="Search orders" placeholder="Search orders" />
    </div>
  )
}
email state

Add it

shell1 line
npx qatjs add input

Field

The label, the control (children), the help or the error (the other field components use it too). As a custom element: <ui-field>.

Field: props
PropTypeAttribute
labelQatNodeproperty only
helpQatNodeproperty only
errorQatNodeproperty only
requiredbooleanyes
disabledbooleanyes
readonlybooleanyes
size'sm' | 'md' | 'lg'yes
placeholderstringyes
namestringyes
idstringyes

TextField

One line of text: label, help or error, prefix/suffix, clear, a counter when `maxLength` is set. As a custom element: <ui-text-field>.

TextField: props
PropTypeAttribute
labelQatNodeproperty only
helpQatNodeproperty only
errorQatNodeproperty only
requiredbooleanyes
disabledbooleanyes
readonlybooleanyes
size'sm' | 'md' | 'lg'yes
placeholderstringyes
namestringyes
valuestringyes
type'text' | 'email' | 'tel' | 'url'yes
prefixQatNodeproperty only
suffixQatNodeproperty only
clearablebooleanyes
maxLengthnumberyes
autocompletestringyes
inputmode'text' | 'email' | 'tel' | 'url' | 'numeric' | 'decimal'yes
TextField: events
EventDetail
on:update:valueCustomEvent<string>

TextArea

Several lines: grows with its text from `rows` (3), a counter when `maxLength` is set. As a custom element: <ui-text-area>.

TextArea: props
PropTypeAttribute
labelQatNodeproperty only
helpQatNodeproperty only
errorQatNodeproperty only
requiredbooleanyes
disabledbooleanyes
readonlybooleanyes
size'sm' | 'md' | 'lg'yes
placeholderstringyes
namestringyes
valuestringyes
rowsnumberyes
maxLengthnumberyes
TextArea: events
EventDetail
on:update:valueCustomEvent<string>

NumberField

A number with its unit and a stepper; ↑/↓ step too. `value` is a number, or null when empty. As a custom element: <ui-number-field>.

NumberField: props
PropTypeAttribute
labelQatNodeproperty only
helpQatNodeproperty only
errorQatNodeproperty only
requiredbooleanyes
disabledbooleanyes
readonlybooleanyes
size'sm' | 'md' | 'lg'yes
placeholderstringyes
namestringyes
valuenumber | nullyes
unitQatNodeproperty only
minnumberyes
maxnumberyes
stepnumberyes
NumberField: events
EventDetail
on:update:valueCustomEvent<number | null>

PasswordField

A password with show and hide, and an optional strength meter (0–4) with its words. As a custom element: <ui-password-field>.

PasswordField: props
PropTypeAttribute
labelQatNodeproperty only
helpQatNodeproperty only
errorQatNodeproperty only
requiredbooleanyes
disabledbooleanyes
readonlybooleanyes
size'sm' | 'md' | 'lg'yes
placeholderstringyes
namestringyes
valuestringyes
strength0 | 1 | 2 | 3 | 4property only
strengthTextQatNodeproperty only
autocompletestringyes
PasswordField: events
EventDetail
on:update:valueCustomEvent<string>

SearchField

A search box: its icon, and a shortcut hint (`hint="⌘K"`); `label` names it (there is no visible label). As a custom element: <ui-search-field>.

SearchField: props
PropTypeAttribute
labelstringyes
valuestringyes
placeholderstringyes
hintstringyes
disabledbooleanyes
size'sm' | 'md' | 'lg'yes
SearchField: events
EventDetail
on:update:valueCustomEvent<string>

Keys

KeyDoes
↑ ↓step a NumberField (the browser’s own)
Escclear a SearchField (the browser’s own)