Input

A headless text input primitive with bindable value state and built-in agent support.

	<script lang="ts">
  import { Input, Label } from "bits-ui";
 
  let value = $state("");
</script>
 
<div class="flex w-full max-w-[290px] flex-col gap-1.5">
  <Label.Root
    for="project-name-demo"
    class="text-sm font-medium text-foreground"
  >
    Project name
  </Label.Root>
  <Input.Root
    id="project-name-demo"
    bind:value
    placeholder="Apollo"
    class="h-input w-full rounded-card-sm border border-border-input bg-background px-3.5 text-sm text-foreground placeholder:text-foreground-alt/50 focus:border-foreground focus:outline-hidden data-filled:border-dark-40"
  />
</div>

Structure

	<script lang="ts">
  import { Input } from "bits-ui";
</script>
 
<Input.Root />

Managing Value State

Two-Way Binding

Use bind:value for automatic state synchronization:

	<script lang="ts">
  import { Input } from "bits-ui";
 
  let name = $state("Apollo");
</script>
 
<Input.Root bind:value={name} placeholder="Project name" />

Callback

Use onValueChange to react whenever the value updates from user input or an agent action:

	<Input.Root value={name} onValueChange={(next) => (name = next)} />

API Reference

Input.Root

A headless text input primitive with bindable value state, styling data attributes, and automatic agent registration.

Property Details
value
onValueChange
disabled
readonly
required
ref
child
Data Attribute Details
data-input-root
data-disabled
data-readonly
data-required
data-filled

Agent Support

Registers as a text input that dispatches native input and change events and automatically redacts password and payment fields.

Auto-secret

Action Description
setValue(value: string)

Updates bind:value and the DOM <input>, dispatching bubbling input and change events.

clear()

Clears the input to "" and dispatches bubbling input and change events.

State Description
component: "input"

Component kind returned in snapshot().

value: string

Current value, or "[redacted]" when secret and non-empty.

type: string

Present when type is set to a value other than "text".

placeholder: string

Present when placeholder is set.

required: true

Present when required is true.

  • Automatically marked secret: true when type="password" or autocomplete includes current-password, new-password, one-time-code, or any cc-* token.
await agent.act({
	steps: [{ ref: "Project name", action: "setValue", args: ["Atlas"] }],
});