Skip to content

Message Input

Get Ritla UI

Pinned under a conversation: an attach button, the text field with an emoji button, and send.

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add message-input

    Also works with shadcn: npx shadcn@latest add @ritla/message-input

  2. Dependencies it brings

    @phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

message-input.tsx
import { MessageInput } from "@/components/ui/message-input";<MessageInput label="Message" placeholder="Write a message" onSend={(text) => send(text)} />

API reference

MessageInput

PropTypeDefaultDescription
placeholderstringNoneFigma's Placeholder.
labelstringNoneThe field's name for screen readers.
onSend(text: string) => voidNoneCalled with the trimmed text; the field then clears.
onAttach / onEmoji() => voidNoneShow the Attach and Emoji buttons.
labels{ attach?, emoji?, send? }NoneThe buttons' names in the page's language.
value / onValueChangestring / (value: string) => voidNoneA controlled draft.
disabledbooleanfalseDisables the field and buttons.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
EnterSends the message.
ShiftEnterAdds a new line.

ARIA

  • The field has a visually hidden label; the placeholder is not a label.
  • The buttons are named Attach, Emoji and Send; Send stays disabled until you type.

Arabic and RTL notes

Mirrors

  • The send arrow points left in Arabic, and Attach starts the row.

Does not mirror

  • The paperclip and the smiley don't mirror.
Numerals
Text is sent as typed.
Arabic typography
Text is body-16.
Mixed-direction text
The field is dir="auto": it follows the first letter you type.