ClickorKeyboard shortcut Alt + L

Dragto resize

Nord Design System SearchDeveloperDeveloperGetting startedUsing Web ComponentsWebfontsCDNLocalizationCSS Framework Legacy ESLint PluginWorking with AIFAQDesignDesignGetting startedFoundationsAccessibilityColor SystemColor UtilitiesPrinciplesFigma ToolkitGridIconographyNamingNordhealth BrandTypographyThemesBrand assetsToolsComponentsComponentsAccordion New Aside New Autocomplete New AvatarBadgeBannerButtonButton GroupCalendarCard Updated Chart New Chat New Chat AttachmentChat ComposerChat Composer DrawerChat Composer InputChat Dictation ButtonChat Layout Scroll ButtonChat MessageChat Message BubbleChat Message ListChat Message MetadataChat Send ButtonChat System MessageChat TokenChat Tokenized TextChat Tool CallsCheckboxCollapsible New Combobox New Command MenuData Table New Date PickerDate Range Picker New DividerDrawer Updated DropdownEmpty StateField New FieldsetFilter Bar New FooterHeaderIconInputInput Group New Item New Kbd New LayoutMessageMeter New Modal Updated NavigationNotificationNumber Field New Otp Field New Outline New Overflow List New Pagination New PopoutProgressProgress BarQrcodeRadioRangeResizable New Rich Text Editor New Scroll Area New Segmented ControlSelectSkeletonSpinnerStackTabTableTagTextareaTime Picker New Timestamp New ToastToggleTooltipTop BarTruncate New Visually HiddenDesign TokensDesign TokensTailwind CSSTailwind CSSBlocksBlocksTemplatesTemplatesIconsIconsPlaygroundPlaygroundLatest UpdatesLatest UpdatesChangelogChangelogMigration guidesMigration guides
GitHub

Clickto expandKeyboard shortcut Alt + L

Chat Composer Input Alpha

Captures form-associated rich plain text with atomic tokens and asynchronous suggestions.

This component is considered alpha. We're still finalising the API, so it may include a breaking change at any time — use it at your own risk.

Usage

Chat Composer Input is the editable Shadow-DOM control for the Chat family. It remains framework-neutral and participates in native forms, reset, validation, input, and change behavior.

import "@nordhealth/components/lib/ChatComposerInput"

Composition

Tokens and suggestions

Tokens stay atomic during selection, deletion, copy, cut, paste, undo, redo, and form serialization. Configure triggers as JavaScript records with a trigger character, synchronous or asynchronous source, and onSelect mapper. Replacement searches cancel the prior AbortSignal, and disconnecting cancels pending work.

Give a trigger renderItem to control how each suggestion is presented — an avatar for a mention, an icon for a command — and set group on items to list them under headings. Suggestions keep one flat arrow-navigation order regardless of grouping, Tab commits the highlighted item, and the highlight is always scrolled into view.

Tokens accept a render function for richer content than a label, and expandable: true adds an action that turns the chip back into editable text. Long pastes converted by paste-as-token are expandable by default, so a collapsed paste stays inspectable rather than only removable. Consumer strings are never parsed as HTML: render returns DOM nodes.

Use insertText(), insertToken(), setSelectionRange(), and setValue() for integration without reaching into Shadow DOM. Native composed events and the typed nord-files, nord-token-change, and nord-token-expand events expose serializable data; applications remain responsible for reading and uploading accepted files.

Owning a keystroke

Built-in Enter and history handling runs only when nothing else has claimed the key. Add a capture-phase keydown listener and call preventDefault() to take a keystroke completely — to make Enter insert a newline on a touch keyboard, or to send on Cmd/Ctrl + Enter. An open suggestion menu still consumes its own keys first, and Enter never submits mid-IME-composition.

Examples

Multiline entry

Enter submits from Composer Input, while Shift + Enter inserts a newline. Set max-rows to limit the visible growth before the editor scrolls; it does not limit the message value or number of lines.

Message history

Arrow Up and Arrow Down recall recent entries when the caret is at the corresponding multiline boundary. This is on by default; add no-history to opt out. Supply the history JavaScript property as an array of strings. The current draft is restored when navigation returns past the newest entry, and successful Composer submissions are recorded automatically. At a valid boundary the input first emits the cancelable nord-history-request event with read-only direction, current value, selectionStart, and selectionEnd fields. Cancel it when the application owns history resolution, including remote or paginated history; otherwise the input applies its local history entry.

Pasted text and files

With paste-as-token, plain text at or above paste-token-threshold becomes one atomic token. The cancelable nord-paste-token event exposes the proposed text and token before insertion, so application policy can reject or replace it without a framework-specific hook.

Pasted or dropped files are checked against accept, max-files, and max-file-size. The nord-files event contains immutable accepted and rejected file metadata. Composer Input never reads or uploads the files; the application owns preview, storage, retry, and removal behavior.

Accessibility

Provide a concise label. The editor exposes multiline textbox semantics and becomes a combobox while suggestions are active, with keyboard navigation, selected/disabled option state, and polite result announcements. Always retain keyboard text entry when pairing it with dictation.

API reference

ChatComposerInput

Form-associated, framework-neutral rich plain-text input. Tokens are atomic, trigger sources may be synchronous or asynchronous, and consumer strings are never parsed as HTML. Native input bubbles for every user-visible change; change commits on blur.

<nord-chat-composer-input></nord-chat-composer-input>

Props

PropertyAttribute Description TypeDefault
namenameForm field name.string | undefined
defaultValuedefault-valueInitial value restored by native form reset.string''
labellabelAccessible label.string | undefined
placeholderplaceholderEmpty-state prompt.string | undefined
maxRowsmax-rowsMaximum visible line count before scrolling.number8
disableddisabledDisables editing and form submission.booleanfalse
requiredrequiredEnables native value-missing validation.booleanfalse
noHistoryno-historyOpts out of Up/Down message history recall. History is on by default: a type: Boolean property defaulting to true cannot be switched off from markup (an absent attribute never reaches the converter), so the opt-out is the inverted attribute, matching Nord's hide-*/no-* convention.booleanfalse
pasteAsTokenpaste-as-tokenConverts matching long plain-text paste to a token.booleanfalse
pasteTokenThresholdpaste-token-thresholdDefault long-paste threshold.number200
interimTextinterim-textTransient aria-hidden dictation text shown without changing the value.string''
acceptacceptNative accept syntax used to validate file metadata.string | undefined
maxFilesmax-filesMaximum accepted files per paste/drop.unknown
maxFileSizemax-file-sizeMaximum accepted file size in bytes.unknown

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: FocusOptions
checkValidity() => voidN/A
reportValidity() => voidN/A
setCustomValidity(message: string) => voidmessage: string
EventDetail TypeDescription
inputEventNative composed input event after user-visible changes.
changeEventNative composed change event on blur after editing.
nord-submitChatComposerSubmitEventStandalone submit intent.
nord-filesChatComposerFilesEventAccepted/rejected file metadata.
nord-history-requestChatComposerHistoryRequestEventCancellable message-history intent at a valid caret boundary.
nord-token-changeChatComposerTokenChangeEventImmutable token snapshot.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-chat-composer-menu-max-block-sizeMaximum suggestion menu block size.16rem