Usage
Chat Dictation Button is the speech data-capture control for the Chat family. It feature-detects standard and prefixed Web Speech recognition and exposes start(), stop(), abort(), and toggle() methods.
import "@nordhealth/components/lib/ChatDictationButton"
Composition
Recognition and integration
Every interim and final update emits nord-transcript; final text also emits nord-dictation-result. Insert final text through Composer Input’s public insertText() method rather than reaching into its Shadow DOM. Repeated starts are ignored, and aborting, disabling, or disconnecting releases recognition listeners.
Examples
Unsupported recognition
The default unsupported-behavior="hide" renders no control when recognition is unavailable. Use disable for a labelled fallback, but always retain ordinary keyboard input.
Accessibility
The owned Nord Button exposes localized labels, pressed/listening state, keyboard activation, and errors. Request microphone access only after explicit user activation. Speech recognition may send audio to a browser, operating system, or remote provider, so disclose the applicable privacy behavior at the point of use.
Templates
See this component composed into complete application views:
API reference
ChatDictationButton
Starts and stops speech-to-text capture for a chat composer. Speech can be
sent to a browser or platform recognition service: disclose that privacy
behavior, request microphone access only after the user's activation, and do
not start capture automatically. Always retain keyboard text entry as the
fallback when Web Speech is unsupported or permission is denied.
Every final transcript emits nord-dictation-result. Composer integration
should listen for that event and call Composer Input's public insertText()
method; this component never reaches through another element's Shadow DOM.
The same methods and bubbling events work from plain HTML, React, Vue, Svelte,
Angular, or any other DOM-capable framework.
<nord-chat-dictation-button></nord-chat-dictation-button>Props
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
unsupportedBehavior | unsupported-behavior | Unsupported browsers either hide the control or expose a disabled fallback. | ChatDictationUnsupportedBehavior | 'hide' |
disabled | disabled | Disables dictation even when the recognition API is available. | boolean | false |
size | size | Nord small or medium button and equalizer geometry. | ChatDictationButtonSize | 'm' |
recognitionLang | recognition-lang | BCP-47 language sent to speech recognition. Defaults to navigator.language. | string | undefined | — |
continuous | continuous | Keep recognition active until explicitly stopped. | boolean | true |
interimResults | interim-results | Request interim transcript updates. | boolean | true |
label | label | Optional accessible label override for both idle and listening states. | string | undefined | — |
Methods
| Method name | Parameters | Description |
|---|---|---|
focus(options?: FocusOptions) => void | options: FocusOptions |
| Event | Detail Type | Description |
|---|---|---|
nord-transcript | ChatTranscriptEvent | Every interim and final transformed transcript. |
nord-dictation-result | ChatDictationResultEvent | Final transformed transcript for application/composer integration. |
nord-dictation-start | ChatDictationStartEvent | Recognition began listening. |
nord-dictation-end | ChatDictationEndEvent | Recognition stopped, aborted, or ended. |
nord-dictation-error | ChatDictationErrorEvent | Permission or recognition failure. |
CSS Properties
CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.
| Property | Description | Default |
|---|---|---|
--n-chat-dictation-button-size | Overrides the Nord Button square size. | — |
Dependencies
This component is internally dependent on the following components:
- <nord-button>
Button
Buttons are used for interface actions. Primary style should be used only once per section for main call-to-action, while other styles can appear more frequently.
- <nord-icon>
Icon
Icons are used to provide additional meaning or in places where text label doesn’t fit. Icon component allows you to display an icon from the Nordicons library.
- <nord-visually-hidden>
VisuallyHidden
Visually hidden is used when an element needs to be available to assistive technologies like screen readers, but be otherwise hidden.