AI

PromptInput

Multi-line input with send button for AI chat.

Available inreactangular

Preview

Live previewreal component

Install

TerminalBash
npx @mcp-elements/cli add prompt-input

Usage

prompt-input-example.tsxTSX
import { PromptInput, PromptInputTextarea, PromptInputFooter, PromptInputActions, PromptInputCharCount } from '@mcp-elements/react'
import { useState } from 'react'

export function Example() {
  const [value, setValue] = useState('')
  return (
    <PromptInput>
      <PromptInputTextarea
        placeholder="Ask anything…"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        rows={2}
      />
      <PromptInputFooter>
        <PromptInputCharCount count={value.length} max={2000} />
        <PromptInputActions>
          <button disabled={!value.trim()}>Send</button>
        </PromptInputActions>
      </PromptInputFooter>
    </PromptInput>
  )
}

Props

PropTypeDefaultDescription
childrenReact.ReactNodeUse PromptInputTextarea, PromptInputFooter, PromptInputActions as children
placeholder (PromptInputTextarea)stringPlaceholder text for the textarea
value (PromptInputTextarea)stringControlled value of the textarea
onChange (PromptInputTextarea)React.ChangeEventHandler<HTMLTextAreaElement>Change handler for the textarea
count (PromptInputCharCount) *numberCurrent character count to display
max (PromptInputCharCount)numberMaximum allowed characters; renders count/max when provided