Skip to content

Chat

ChatComposer

Composer chrome around the message input and trailing actions.

import { ChatComposer } from '@var-ui/react';

ChatComposer

Bordered composer chrome around the message input and trailing actions. Pair with ChatComposerInput for the auto-resizing textarea and ChatSendButton for send/stop.

Examples

Default

There is no @var-ui/astro ChatComposer — Astro and HTML previews show static core-recipe chrome; Enter-to-submit is React-only.

Demo.tsxTSX
import { useState } from 'react';
import { ChatComposer, ChatComposerInput, ChatSendButton } from '@var-ui/react';

function Composer() {
  const [value, setValue] = useState('');
  return (
    <ChatComposer actions={<ChatSendButton onClick={() => setValue('')} />}>
      <ChatComposerInput
        value={value}
        onValueChange={setValue}
        onSubmit={() => setValue('')}
        placeholder="Type a message…"
      />
    </ChatComposer>
  );
}

ChatComposerInput

PropTypeDefault
valuestring(required)
onValueChange(value: string) => void(required)
onSubmit(value: string) => void(required)
submitOn'enter' | 'mod+enter''enter'
placeholderstring'Type a message…'
maxRowsnumber8
disabledbooleanfalse
classNamestring—

With the default submitOn="enter", Enter submits (trimmed, non-empty only) and Shift+Enter inserts a newline. submitOn="mod+enter" submits on ⌘/Ctrl+Enter and lets every Enter insert newlines.

Props

Accessibility

Built on React Aria TextField / TextArea.