Skip to content

Composer

Stable

The box where people type a message, with attach, tools and send or stop.

Also known as chat input, prompt input, message input, chat box

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Default

Send stays off until something is typed. Try Enter, then Shift and Enter.

When to use it

The one place people type to the assistant. Send turns into Stop while a reply is being written, so the main button always does what matters right now.

Made of: Text box · Attach button (only if files are allowed) · Tools area · Character counter · Send or Stop button

Use it for

  • The message box at the bottom of a conversation.
  • A message box inside a Tray on a landing screen.
  • A chat where people may need to stop a long reply.

Not for

  • Describing something to make, such as an image, where Enter should add a line: use PromptBox.
  • A short one-line search or filter field.

Do and avoid

Do. A clear hint tells people what they can ask.
Type here
Avoid. A plain box has no send button, so people are left guessing.

Do

  • Keep one Composer at the bottom of the conversation, as wide as the messages.
  • Always let people stop a reply while it is being written.
  • Put choices such as project or model beside Send.
  • Set the limit to the real one so the counter is honest.
  • Pass onAttach only when your app can really take files. The button appears whenever it is set.
  • Pass onStop whenever you set generating, so Stop really stops the reply.

Avoid

  • Do not show the attach button if your app cannot take files. A button that does nothing is confusing.
  • Do not show more than one Composer in the same conversation.
  • Do not add a second send button. Enter and the green button already cover it.
  • Do not use the green Send button for anything else. Green marks the one main send action.

On a phone

  • The text box is 16px on a touch screen so the page does not zoom on focus, and it grows up to 200px tall as the person types.
  • The attach, tools and send controls wrap onto their own line when they do not fit. Each has a 44px tap area on a touch screen.
  • The phone keyboard is asked to show a send key. Enter sends and Shift+Enter adds a new line, which is hard to reach on a phone, so people cannot easily write a second line.
  • It does no keyboard or safe-area handling of its own, so keep it above the on-screen keyboard and the bottom safe area yourself.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started