This is your public display name.
placeholdertypedisabledaria-invalidimport { Input } from "@/components/ui/input"
export function UsernameField() {
return (
<div className="w-full max-w-sm space-y-2">
<label htmlFor="username" className="text-sm font-medium">
Username
</label>
<Input
id="username"
placeholder="Enter your username"
/>
<p className="text-sm text-muted-foreground">This is your public display name.</p>
</div>
)
}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.
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>
);
}import { Input } from '@/components/ui/input';
export function Example() {
return <Input placeholder="Enter your email" />;
}import { Input } from '@/components/ui/input';
export function Example() {
return (
<div className="space-y-4 w-full max-w-md">
<div className="space-y-2">
<label htmlFor="email" className="text-sm font-medium text-foreground">Email</label>
<Input
id="email"
type="email"
placeholder="user@example.com"
/>
</div>
<div className="space-y-2">
<label htmlFor="password" className="text-sm font-medium text-foreground">Password</label>
<Input
id="password"
type="password"
placeholder="Enter your password"
/>
</div>
<div className="space-y-2">
<label htmlFor="number" className="text-sm font-medium text-foreground">Number</label>
<Input
id="number"
type="number"
placeholder="Enter a number"
/>
</div>
</div>
);
}import { Input } from '@/components/ui/input';
export function Example() {
return (
<div className="space-y-4 w-full max-w-sm">
<div className="space-y-2">
<label htmlFor="disabled" className="text-sm font-medium text-foreground">Disabled Input</label>
<Input
id="disabled"
placeholder="This input is disabled"
disabled
/>
</div>
<div className="space-y-2">
<label htmlFor="readonly" className="text-sm font-medium text-foreground">Read-only Input</label>
<Input
id="readonly"
value="This input is read-only"
readOnly
/>
</div>
</div>
);
}import { Input } from '@/components/ui/input';
import { useState } from 'react';
export function Example() {
const [email, setEmail] = useState('');
const [error, setError] = useState('');
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
setEmail(value);
if (value && !value.includes('@')) {
setError('Please enter a valid email address');
} else {
setError('');
}
};
return (
<div className="space-y-2 w-full max-w-sm">
<label htmlFor="email-validation" className="text-sm font-medium text-foreground">Email Address</label>
<Input
id="email-validation"
type="email"
placeholder="user@example.com"
value={email}
onChange={handleChange}
aria-invalid={!!error}
/>
{error && (
<p className="text-sm text-destructive">{error}</p>
)}
{email && !error && (
<p className="text-sm text-success">Valid email address</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
details.cancel() refuses an agent's change.file input takes no agent actions.Agent
Inside an AgentProvider, it appears in agent.snapshot() as input.
Reads
labelThe aria-label, the associated label, then the placeholder or name.
valueThe current text. Redacted for passwords and secret autocomplete fields.
disabledTrue when the input is disabled.
requiredTrue when the input is required.
invalidTrue when aria-invalid is set or the Field is invalid.
errorsThe 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,
FieldLabelor aria-label. A placeholder vanishes on typing. - Set aria-invalid when the value is wrong; it is styled and announced.