Components · engine.field · version 0.1.0
Field
Gives one control a visible label, a description and an error message, and relates them to it.
Preview
Every variant in every state, drawn by the same definition that the Figma sync and the tests use.
| Component | rest | invalid |
|---|---|---|
| field | Description | DescriptionError message |
Install
npm install @uiuxengine/reactComponents come from npm and stay identical to their definition and their Figma component. See Installation.
Usage
import { Field, Input } from "@uiuxengine/react";
export function Example() {
return (
<Field
label="Label"
description="Description"
error="Error message"
control={<Input placeholder="Placeholder" />}
/>
);
}Guidelines
- Use a field for every input or select that has a visible label.
- Keep the label short. Put instructions and formats in the description.
- Set invalid and error together while the host shows why the value is wrong. Say how to fix it.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required | text, up to 120 | — | Names the control. |
description | text, up to 300 | — | Help shown under the control. |
error | text, up to 300 | — | Why the value is wrong, shown while invalid. |
invalid | boolean | false | Marks the control as invalid and shows the error. |
Slots
| Slot | Takes | Description |
|---|---|---|
control | engine.input, engine.select | The control the field names. |
Accessibility
- Renders a native <div> with the role
generic. - Its
labelpart names the control incontrol. - Its
descriptionanderror, when shown, describe it. invalidis announced on it asaria-invalid.
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.
Description
No actions yet.
JSON Schema of the props
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:uiuxengine:component:engine.field@0.1.0",
"title": "field",
"description": "Gives one control a visible label, a description and an error message, and relates them to it.",
"type": "object",
"properties": {
"label": {
"description": "Names the control.",
"type": "string",
"maxLength": 120
},
"description": {
"description": "Help shown under the control.",
"type": "string",
"maxLength": 300
},
"error": {
"description": "Why the value is wrong, shown while invalid.",
"type": "string",
"maxLength": 300
},
"invalid": {
"description": "Marks the control as invalid and shows the error.",
"type": "boolean",
"default": false
},
"control": {
"description": "The control the field names.",
"type": "object",
"properties": {
"component": {
"enum": [
"engine.input",
"engine.select"
]
},
"props": {
"type": "object"
}
},
"required": [
"component"
],
"additionalProperties": false
}
},
"required": [
"label",
"control"
],
"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
}
}
}