Input

A single line of text, typed by a person or agent.

Source
$npx @dinachi/cli@latest add input

This is your public display name.

placeholder
type
disabled
aria-invalid

Usage

import { Input } from "@/components/ui/input"

export function ProjectName() {
  return (
    <div className="space-y-2">
      <label htmlFor="project">Project name</label>
      <Input id="project" placeholder="Atlas" />
    </div>
  )
}

Examples

This is your public display name.

A label and helper text tied to the field.
import { Input } from '@/components/ui/input';

export function Example() {
  return (
    <div className="space-y-2 w-full max-w-sm">
      <label htmlFor="username" className="text-sm font-medium text-foreground">Username</label>
      <Input 
        id="username" 
        placeholder="Enter your username" 
      />
      <p className="text-sm text-muted-foreground">
        This is your public display name.
      </p>
    </div>
  );
}

Notes

Labels and fields

Pair the input with a <label htmlFor> or wrap it in a Field with a FieldLabel. Inside a Field, an agent's write marks it dirty and filled like typing.

API

valuestring
Controlled value.
defaultValuestring
Starting value when uncontrolled.
onValueChange
agent
(value, details) => void
Runs for people and agents. details.cancel() refuses an agent's change.
onChange(event) => void
The native change handler. Runs for typing and for an agent's write.
type
agent
string = "text"
The native input type. A file input takes no agent actions.
placeholder
agent
string
Shown while empty. The agent's name for the field when nothing else labels it.
disabled
agent
boolean = false
Blocks people and agents.
readOnly
agent
boolean = false
Readable and selectable; refuses an agent's write.
aria-invalid
agent
boolean
Draws the error border and ring. The agent reads it as invalid.

Agent

Inside an AgentProvider, it appears in agent.snapshot() as input.

Reads

label

The aria-label, the associated label, then the placeholder or name.

value

The current text. Redacted for passwords and secret autocomplete fields.

disabled

True when the input is disabled.

required

True when the input is required.

invalid

True when aria-invalid is set or the Field is invalid.

errors

The messages aria-errormessage points to, while invalid.

Actions

setValue("Atlas")

Replaces the text with a real input event, so onChange and a Field see it.

clear()

Empties the field the same way.

An agent's write runs through onValueChange first. isAgentChange(details) is true for it; details.cancel() refuses it before onChange or the Field see it, and the agent is told the app refused. A disabled or readOnly input refuses on its own, and a type="file" input offers no actions.

await agent.act({
  steps: [{ ref: "Username", action: "setValue", args: ["ada"] }],
})

Accessibility

  • Renders a native input with native semantics and keyboard handling.
  • Name every input with a label, FieldLabel or aria-label. A placeholder vanishes on typing.
  • Set aria-invalid when the value is wrong; it is styled and announced.