# PromptInput

Chat composer: auto-grow textarea with a toolbar of research/grounding pills, model picker, attach/screenshot/voice, and send.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/prompt-input.tsx)

## Live preview

[Open live prompt-input preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=prompt-input&theme=studio-utility)

## Install

```bash
netscript ui:add prompt-input
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import { PromptInput } from '@app/components/ui/prompt-input.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><PromptInput placeholder="Ask about an order…" onSubmit={(text) => report(text)} /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `PromptInputProps` | `placeholder` | `string` | Yes |  |
| `PromptInputProps` | `onSubmit` | `(text: string, meta: PromptSubmitMeta) => void` | Yes |  |
| `PromptInputProps` | `models` | `ModelOption[]` | Yes |  |
| `PromptInputProps` | `model` | `string` | Yes |  |
| `PromptInputProps` | `onModelChange` | `(id: string) => void` | Yes |  |
| `PromptInputProps` | `grounding` | `boolean` | Yes |  |
| `PromptInputProps` | `onGroundingChange` | `(next: boolean) => void` | Yes |  |
| `PromptInputProps` | `research` | `boolean` | Yes |  |
| `PromptInputProps` | `onResearchChange` | `(next: boolean) => void` | Yes |  |
| `PromptInputProps` | `hint` | `string` | Yes |  |
| `PromptInputProps` | `compact` | `boolean` | Yes |  |
| `PromptInputProps` | `class` | `string` | Yes |  |
| `PromptInputProps` | `onAttach` | `() => void` | Yes |  |
| `PromptInputProps` | `onScreenshot` | `() => void` | Yes |  |
| `PromptInputProps` | `onVoice` | `() => void` | Yes |  |
| `PromptInputProps` | `leadingActions` | `ComponentChildren` | Yes |  |
| `PromptInputProps` | `trailingActions` | `ComponentChildren` | Yes |  |
| `PromptInputProps` | `busy` | `boolean` | Yes |  |
| `PromptInputProps` | `onStop` | `() => void` | Yes |  |
| `PromptInputProps` | `sendDisabled` | `boolean` | Yes |  |
| `PromptInputProps` | `submitKey` | `PromptSubmitKey` | Yes |  |

```typescript
type PromptSubmitKey = [object Object]
PromptInputProps extends Omit<JSX.HTMLAttributes<HTMLFormElement>, "class" | "onSubmit">
```

## Keyboard

| Key | Action |
| --- | --- |
| `Enter` | Submit only with submitKey=enter and without Shift/IME composition; otherwise native text entry |
| `Control+Enter/Meta+Enter` | Submit with submitKey=mod-enter unless composing |
| `Tab/Shift+Tab` | Move through textarea and native controls |
| `Enter/Space` | Activate focused action button |

## Tokens

Semantic contract roles: `border/input`, `radius/card`, `space/inline/gap`, `space/stack/gap`, `surface/card`, `text/muted`.

CSS custom properties referenced directly: `--ns-border`, `--ns-border-hover`, `--ns-border-width`, `--ns-card`, `--ns-control-h`, `--ns-control-h-sm`, `--ns-control-height`, `--ns-control-height-sm`, `--ns-control-padding-x-sm`, `--ns-ease-fast`, `--ns-ease-normal`, `--ns-fg`, `--ns-focus-ring-offset`, `--ns-focus-ring-width`, `--ns-font-mono`, `--ns-font-sans`, `--ns-inline-gap`, `--ns-input-border`, `--ns-leading-body`, `--ns-leading-caption`, `--ns-leading-normal`, `--ns-marker`, `--ns-muted`, `--ns-muted-fg`, `--ns-primary`, `--ns-primary-border`, `--ns-primary-fg`, `--ns-primary-hover`, `--ns-primary-stroke`, `--ns-primary-subtle`, `--ns-radius-2xl`, `--ns-radius-card`, `--ns-radius-control`, `--ns-radius-full`, `--ns-radius-md`, `--ns-ring`, `--ns-selected`, `--ns-shadow-sm`, `--ns-space-1`, `--ns-space-1-5`, `--ns-space-2`, `--ns-space-2-5`, `--ns-space-3`, `--ns-space-px`, `--ns-stack-gap`, `--ns-state-disabled-opacity`, `--ns-state-pressed-opacity`, `--ns-text-2xs`, `--ns-text-body`, `--ns-text-caption`, `--ns-text-chat`, `--ns-text-sm`, `--ns-tracking-body`, `--ns-tracking-caption`, `--ns-weight-body`, `--ns-weight-caption`.

## Contract and compatibility

Accessibility pattern: native form, textarea and buttons

- Native DOM attributes pass through where the implementation accepts them.
- Utility compatibility anatomy is included for existing shipped helpers; it does not implement a design gap.

Design contract values marked planned are not implementation props. The props above describe what ships today.
