# ChatInput

> Cherry ChatInput component - the auto-growing chat composer with an optional animated rainbow glow.

Source: https://cherry.al/code/chat-input

> For the complete documentation index, see [llms.txt](https://cherry.al/llms.txt).

# ChatInput

<iframe className="light-only" src="https://demo.cherry.al/preview/chat-input-glow?theme=light" title="Chat composer with glow" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />
<iframe className="dark-only" src="https://demo.cherry.al/preview/chat-input-glow?theme=dark" title="Chat composer with glow" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />

ChatInput is the [chat kit](/code/chat)'s composer: an auto-growing textarea plus a send button, wired to the provider out of the box. Enter submits, Shift+Enter breaks the line, and an IME composition session owns Enter until it commits. The send button is disabled while the input is empty or a reply is loading, and shows a [Spinner](/code/spinner) in place of its arrow while loading.

Inside a `ChatProvider` no props are required - value, change handling, submission, and the loading state all come from the provider:

```jsx
<ChatProvider onSend={handleSend}>
  <ChatPanel>
    <Transcript />
    <ChatInput $glow />
  </ChatPanel>
</ChatProvider>
```

Outside a provider (or to intercept it), drive it yourself with `value`, `onValueChange`, `onSend`, and `$loading`.

The textarea grows with its content up to a cap (160px by default, or `$maxRows`), then scrolls. At one row it matches the height of Cherry's other form elements.

## The glow treatment

`$glow` opts into the animated treatment: a rotating rainbow border that stands in for the primary color on hover and focus, a soft radiating halo, and a field of floating sparkles while the composer is hovered or focused. The state map mirrors the regular Cherry input - border accent on hover and focus, a ring growing to 4px on focus, held at 2px while pressed. All of it is disabled under `prefers-reduced-motion: reduce`.

## Properties

<Field value="value" type="string">
  Controlled value. Defaults to the provider's `input` state.
</Field>

<Field value="onValueChange" type="(value: string) => void">
  Change handler. Defaults to the provider's `setInput`.
</Field>

<Field value="onSend" type="(value: string) => void">
  Submit handler. Defaults to the provider's `send()`.
</Field>

<Field value="$loading" type="boolean">
  Overrides the provider's loading state.
</Field>

<Field value="$glow" type="boolean">
  The animated rainbow border and sparkle treatment. Off by default.
</Field>

<Field value="$glowColors" type="string[]">
  Overrides the glow palette with your own list of colors.
</Field>

<Field value="$maxRows" type="number">
  Maximum number of rows the textarea may grow to before it scrolls.
</Field>

<Field value="placeholder" type="string">
  Defaults to `"Ask AI Assistant..."`.
</Field>

<Field value="aria-label" type="string">
  Accessible name for the textarea. Defaults to `"Ask a question"`.
</Field>

All other native textarea attributes (except the controlled `value`/`onChange`/`onSubmit`) pass through, and the ref forwards to the textarea element.

<Button href="https://github.com/cherry-design-system/styled-components/blob/main/src/lib/chat-input.tsx" icon="code" iconPosition="left">
  View Source
</Button>
