Field, Input & Textarea
Labelled text inputs with descriptions and errors wired up for screen readers.
Example
Shown on the lock screen
Enter a complete email address
import { Field, Input, Textarea } from "@porcelana/ui";
import { SearchIcon } from "@porcelana/icons";
export default function Example() {
return (
<div style={{ display: "grid", gap: 16, maxWidth: 420 }}>
<Field label="Alarm label" description="Shown on the lock screen" required>
<Input defaultValue="Morning run" />
</Field>
<Field label="Notify email" error="Enter a complete email address">
<Input type="email" defaultValue="pierre@" />
</Field>
<Field label="Note">
<Textarea placeholder="Anything to remember at 06:00?" />
</Field>
<Input aria-label="Search" placeholder="Search" icon={<SearchIcon size={18} />} />
</div>
);
}Import
import { Field, Input, Textarea, Label } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
Field
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | ReactElement<Record<string, unknown>, string | JSXElementConstructor<any>> | – | A single control element (Input, Textarea, Select trigger…). |
labelrequired | ReactNode | – | Visible label, linked to the control. |
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
description | ReactNode | – | Help text under the control; added to aria-describedby. |
disabled | boolean | – | Prevents interaction and dims the control. |
error | ReactNode | – | Error message. Sets aria-invalid on the control and is announced. |
id | string | – | Overrides the generated id passed to the control. |
required | boolean | – | Marks the control as required in forms. |
Input
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
disabled | boolean | – | Prevents interaction and dims the control. |
icon | ReactNode | – | Leading icon, e.g. a search glyph. Decorative. |
id | string | – | Element id. Generated automatically when omitted. |
invalid | boolean | – | Error styling and aria-invalid. Field sets this for you when it has an error. |
placeholder | string | – | Hint shown when there is no value. |
required | boolean | – | Marks the control as required in forms. |
type | "button" | "submit" | "reset" | – | Button type (defaults to "button"). |
Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
disabled | boolean | – | Prevents interaction and dims the control. |
id | string | – | Element id. Generated automatically when omitted. |
invalid | boolean | – | Error styling and aria-invalid. Field sets this for you when it has an error. |
placeholder | string | – | Hint shown when there is no value. |
required | boolean | – | Marks the control as required in forms. |
Label
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
id | string | – | Element id. Generated automatically when omitted. |
Accessibility
- Field links the label with htmlFor and joins description and error into aria-describedby.
- error sets aria-invalid on the control and announces the message with role="alert".
- required adds aria-required and a visual asterisk that screen readers skip.
Mobile
- Inputs use a 16px font so iOS doesn't zoom in on focus.
- 48px tall fields.