Message field
ProA rounded field for writing something to send (a comment, a reply, a chat message) that grows from a pill into a box, with a send button, tools that open into their own row on focus, a reply banner, attachments and suggestions while typing (people after @, tags after #, emoji after :); plus its trigger. Not an M3 component (@windmorph/react-pro).
import { MessageField, MessageFieldFrame, MessageFieldTrigger, MessageFieldSend, useMessageField, useMessageFieldInput, useCoarsePointer } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action | Where |
|---|---|---|
| Enter | Sends, with submitOn="enter" (the default) on a computer. On a touch screen, with submitOn="mod-enter" or "none", it starts a new line. Enter that confirms an input method's candidate never sends.In the text | In the text |
| Shift + Enter | Starts a new line.In the text | In the text |
| Ctrl + Enter | Sends, with submitOn "enter" or "mod-enter" (⌘ + Enter on a Mac).In the text | In the text |
| Escape | Dismisses the suggestion list while it (or its loading row) shows, until what follows its @, # or : changes; otherwise calls onEscape when given, for example to cancel a reply.In the text | In the text |
| Arrow Up or Arrow Down | Moves the active suggestion up or down the list, wrapping, and scrolls it into the list’s view; it shows the focus layer and an inset focus ring.With a suggestion list open | With a suggestion list open |
| Enter or Tab | Puts the active suggestion in (@Name , #tag or the emoji) in place of what was typed, instead of sending or leaving the field. With Shift, Ctrl or ⌘ they stay the field’s: Shift + Enter still starts a new line and Ctrl + Enter still sends.With a suggestion list open | With a suggestion list open |
| Arrow Left or Arrow Right | Moves between the tools, wrapping at the ends.In the tools | In the tools |
| Home or End | Moves to the first or last tool.In the tools | In the tools |
| Enter or Space | Sends. Focus and the caret stay in the text.On Send | On Send |
| Enter or Space | Presses MessageFieldTrigger, or follows it with href (Enter only).On MessageFieldTrigger | On MessageFieldTrigger |
- Nothing is sent while the text is blank (unless
sendable), overmaxLength, or already sending. - A suggestion list opens only as the text changes (with
mentions,tagsoremojiSuggestions), never as the caret moves, and@,#and:open one only at the start of the text or after a space (@and:also after opening punctuation), so times and addresses never do. - The tools are mirrored in right-to-left text, and so are the slots and the counter. Arrow keys in the toolbars follow the laid-out direction, including a
dir="rtl"region of a left-to-right app.
Screen reader
- Role
- The text is a
textarea. The tools are atoolbarof buttons; Send, the banner close and the slot buttons are icon buttons.MessageFieldTriggeris abutton, or alinkwithhref. A suggestion list is alistboxofoptions, in a popover outside the field. - Accessible name
- The text is named by the visible
label,aria-labeloraria-labelledby; the types require one, so the placeholder is never the only name. The tools toolbar is namedlabels.tools("Tools"), Sendlabels.send("Send", also its tooltip) and the banner closelabels.closeBanner("Close").MessageFieldTriggeris named by its prompt, or itsaria-label. The suggestion lists are namedlabels.mentionSuggestions("People to mention"),labels.tagSuggestions("Tags") andlabels.emojiSuggestions("Emoji suggestions"); each option by its label, and an emoji by its name and the shortcode shown. - States announced
- The text has
aria-invalid(also while overmaxLength) andaria-required, andaria-describedbylinkssupportingTextanderrorMessage. Send is disabled while there is nothing to send. While sending it stays focusable witharia-disabled, its name gainslabels.sending("Send, Sending"), and the field announceslabels.sendingpolitely when a send starts (the core IconButton's pending state; its loading indicator is hidden from assistive tech and shows after 200ms). Withmentions,tagsoremojiSuggestionsthe text hasaria-autocomplete="list"; while a list shows it points at it (aria-controls) and at the active suggestion (aria-activedescendant), which isaria-selected.
- The error is an
alertregion that goes into the page before its message, so screen readers announce the message when it arrives. While it shows, the supporting text is visually hidden but still read. - A polite live region announces the limit once per change:
labels.nearLimitfromcounterThreshold, thenlabels.atLimitandlabels.overLimit. The visible counter is hidden from assistive tech. MessageFieldTrigger's avatar, tools and trailing icon are decorative (aria-hidden).- A second polite live region announces
labels.sendingwhen a send starts while focus is in the text. - A polite status says how many suggestions the list shows (
labels.mentionResults,labels.tagResults,labels.emojiResults: "3 people", "2 tags", "5 emoji"). It goes into the page before its first count, so the first count is announced too. A slow search, or the emoji data loading, shows a loading indicator namedlabels.mentionLoading,labels.tagLoadingorlabels.emojiLoading. - Avatars, tag icons and emoji in a suggestion list are decorative (
aria-hidden): the option's name carries them.
Focus
- The text, the tools (one Tab stop), the slot buttons and Send are in Tab order. With
toolbarPlacementbelow the text, the toolbar row follows the text in Tab order. Pressing the field anywhere outside its controls puts the caret in the text, and so do Send and the banner close. - Keyboard focus in the text draws M3's focus indicator around the whole field: a 3px
secondaryoutline 2px outside; pointer focus draws only the thicker focus border. - Focus stays in the text while a suggestion list is open: the list is pointed at, not focused, and pressing a suggestion picks it without taking focus. The suggestion reached with the arrow keys shows the focus layer and an inset focus ring; in forced-colours mode it is outlined in
Highlight. - Putting the caret back in the text (after a press on the field, Send, the banner close or
insertText) never scrolls the page. The app's ownfocus()brings a field that is wholly off screen into view with a nearest, smooth scroll (instant under reduced motion).
Touch target
- The field is 40, 48 or 56px tall (
sm,md,lg). Its buttons are extra-small or small icon buttons with 48 × 48px touch targets, spaced 48px apart so the targets never overlap. - Its icon buttons stay at density 0 in a dense theme, so their targets keep their size and spacing while the field keeps its height.
MessageFieldTriggeris as tall as the field; atsm(40px) it gets an invisible 48 × 48px touch target. It grows with larger text instead of cutting it.
Motion
- Under reduced motion nothing moves or scales: rows open, Send appears and the field grows without movement, and an invalid send does not shake the field. The fades stay on their effects timing, so the rows, Send, its icon and the loading indicator still fade in and out.
- The press ripple appears at full size without growing, and corner changes snap.
- A suggestion list opens and closes as the core menu does, so under reduced motion it loses its movement.
What you need to do
- Name the field (
label,aria-labeloraria-labelledby) for what is being written ("Write a comment"), not only with a placeholder. - Give every tool an
aria-label, and translate every built-in word throughlabels, including the limit announcements and the suggestion lists' names, loading words and counts. - With
mentionsortags, give each suggestion alabelthat names it: it is the option's name and the text put in. - Explain a failed send in
errorMessagewithinvalid, and keeppendingon while a send is in flight. - The field announces nothing when it refuses a pasted or dropped file off
accept: handleonFilePick(oronFileReject) and say why in words a screen reader hears too, such as a snackbar, once for the whole paste or drop. - In forced-colours mode the field's border is
CanvasText,Highlightwhile focused andGrayTextwhile disabled; keepclassNamesoverrides from removing it.