DocsComponentsTemplatesThemesGitHub

PromptInput

Auto-growing composer: Enter sends, Shift+Enter new line, attach, tools, model slot, send/stop.

Code

import * as React from 'react';
import { AttachmentChip, Badge, Chip, PromptInput } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        maxWidth: 640,
      }}
    >
      <PromptInput
        {...{
          onAttach() {},
        }}
        attachments={
          <AttachmentChip
            name="brief.pdf"
            {...{
              onRemove() {},
            }}
          />
        }
        tools={
          <Chip icon="search" selected={false}>
            Web search
          </Chip>
        }
        model={<Badge>Fast</Badge>}
      />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { PromptInput } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/prompt-input.json

Guidelines

  • While the agent runs set busy (send becomes Stop).
  • Put AttachmentChips in attachments, a ModelPicker in model, tool toggles in tools.

Props

PropTypeRequired
valuestringNo
defaultValuestringNo
onChange(value: string) => voidNo
onSubmit(value: string) => voidNo
onStop() => voidNo
onAttach() => voidNo
busybooleanNo
placeholderstringNo
attachmentsReact.ReactNodeNo
toolsReact.ReactNodeNo
modelReact.ReactNodeNo
maxHeightnumberNo
labelstringNo
classNamestringNo

Edit this example on GitHub