Components · engine.input · version 0.1.0
Input
A single line of text that a person types. Takes part in forms like a native input.
Preview
Every variant in every state, drawn by the same definition that the Figma sync and the tests use.
| Component | rest | disabled | readOnly | readOnly, disabled | invalid | invalid, disabled | invalid, readOnly | invalid, readOnly, disabled | focus | focus, readOnly | focus, invalid | focus, invalid, readOnly |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| input |
Install
npm install @uiuxengine/reactComponents come from npm and stay identical to their definition and their Figma component. See Installation.
Usage
import { Input } from "@uiuxengine/react";
import { IconEnvelope } from "@uiuxicons/react/icons/envelope";
export function Example() {
return (
<Input placeholder="Placeholder" accessibleLabel="Input" leadingIcon={IconEnvelope} />
);
}Guidelines
- Name every input: put it in a field, or use accessibleLabel or a label element that points at its id.
- The placeholder is an example of what to type, not a label, and it disappears as a person types.
- Act on valueCommit, when a person leaves the field or presses Enter, rather than on every keystroke.
- Set invalid while the host shows a validation message for it. The input doesn't set it by itself.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | "text" | "email" | "url" | "tel" | text | What kind of text it takes. The browser checks email and url values. |
accessibleLabel | text, up to 160 | — | Accessible name, when no field or label element names the input. |
placeholder | text, up to 120 | — | An example of what to type. |
name | text, up to 120 | — | The field name the value is submitted as. |
autocomplete | text, up to 120 | — | What the browser may fill in, such as 'email' or 'off'. |
required | boolean | false | A form can't be submitted empty. |
minLength | integer | — | The fewest characters a person may submit. |
maxLength | integer | — | The most characters a person can type. |
readOnly | boolean | false | Shows the value and submits it, but a person can't change it. |
disabled | boolean | false | Prevents interaction. |
invalid | boolean | false | Marks the value as invalid, while the host shows why. |
Slots
| Slot | Takes | Description |
|---|---|---|
leadingIcon | icon | Shown before the text. |
Events
valueChange- A person edited the text, once per edit and once for a whole composition, or a form reset the input.
valueCommit- A person left the field after an edit, or pressed Enter.
Accessibility
- Renders a native <div> with the role
generic.
As a spec
Agents describe interfaces as JSON specs. A spec renders only after it validates against the installed contracts, the approved icons and the host's actions. Edit it to see.
No actions yet.
JSON Schema of the props
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:uiuxengine:component:engine.input@0.1.0",
"title": "input",
"description": "A single line of text that a person types. Takes part in forms like a native input.",
"type": "object",
"properties": {
"type": {
"description": "What kind of text it takes. The browser checks email and url values.",
"type": "string",
"enum": [
"text",
"email",
"url",
"tel"
],
"default": "text"
},
"accessibleLabel": {
"description": "Accessible name, when no field or label element names the input.",
"type": "string",
"maxLength": 160
},
"placeholder": {
"description": "An example of what to type.",
"type": "string",
"maxLength": 120
},
"name": {
"description": "The field name the value is submitted as.",
"type": "string",
"maxLength": 120
},
"autocomplete": {
"description": "What the browser may fill in, such as 'email' or 'off'.",
"type": "string",
"maxLength": 120
},
"required": {
"description": "A form can't be submitted empty.",
"type": "boolean",
"default": false
},
"minLength": {
"description": "The fewest characters a person may submit.",
"type": "integer",
"minimum": 0
},
"maxLength": {
"description": "The most characters a person can type.",
"type": "integer",
"minimum": 0
},
"readOnly": {
"description": "Shows the value and submits it, but a person can't change it.",
"type": "boolean",
"default": false
},
"disabled": {
"description": "Prevents interaction.",
"type": "boolean",
"default": false
},
"invalid": {
"description": "Marks the value as invalid, while the host shows why.",
"type": "boolean",
"default": false
},
"leadingIcon": {
"$ref": "#/$defs/iconRef",
"description": "Shown before the text."
}
},
"additionalProperties": false,
"$defs": {
"iconRef": {
"type": "object",
"description": "A reference to an icon in the host's approved catalog.",
"properties": {
"type": {
"const": "icon"
},
"id": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
},
"style": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
},
"weight": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
}
},
"required": [
"type",
"id"
],
"additionalProperties": false
}
}
}