AI
Conversation surface and AI entry points, including the badge that marks generated content.
Purpose
The assistant component family — everything an AI surface in a HealthMetrics product is built from: entry points, the conversation itself, source citations and the prompt input. These are the only components allowed to use the reserved AI palette (Stream cyan on Dark-Surface navy, per the brand usage rules) — which is the point: anything on that palette is the assistant, and nothing else is.
Parts
Six parts, composed rather than configured:
AIBadge— marks AI-generated content, in or out of the conversation.AskAIButton— the primary entry point; a deep-gradient button with the stream glyph.AssistantFAB— floating launcher, pinned bottom-right (floating={false}for in-flow).AIMessage— the conversation bubble;role2="ai" | "user"sets alignment, avatar and colour.AICitationCard— grounds an answer in a source; a linked card with title, snippet and origin.AIPromptComposer— the prompt input: suggestion chips, optional attach, and send.
Conversation
AIMessage handles both sides. The AI bubble sits left on the branded gradient surface
(--gradient-ai, identical in both themes) and carries the badge automatically; the
user bubble sits right on the accent surface with an initials avatar derived from
author. Citations follow the answer they ground, marked with a stream accent edge.
What is my remaining dental entitlement this year?
Entry points & badge
Two entry points and the marker. The FAB pins itself to the bottom-right of the viewport
by default — pass floating={false} to render in flow, as here. Both button and badge
take children to replace the default "Ask AI" / "AI" text.
Generated summary
Prompt composer
Suggestion chips fill the draft (they do not send), attach appears only when onAttach
is provided, and send is disabled while the draft is empty. Enter sends; Shift+Enter
inserts a newline.
Enter sends · Shift+Enter adds a line
import { AIMessage, AIPromptComposer } from "@healthmetrics/ui/ai";
<AIMessage role2="user" author="Aisyah">What is my dental limit?</AIMessage>
<AIMessage role2="ai">
<p>Your dental entitlement is MYR 500 per year; MYR 320 remains.</p>
</AIMessage>
<AIPromptComposer
suggestions={["Check my entitlement"]}
onSend={(prompt) => ask(prompt)}
onAttach={openFilePicker}
disabled={isResponding}
/>Structure
The reserved palette plus the part-level tokens.
| Property | Value |
|---|---|
| AI surface | --brand-navy fill with --brand-stream accents — reserved for this family; a 1px --border hairline appears in dark mode, where the elevated card shares the navy hex |
| Badge | 11px semibold, navy fill, stream text, rounded-sm, 12px auto_awesome glyph |
| Ask AI button | 40px tall (h-10), navy fill, white text, 18px stream glyph, --shadow-2 |
| FAB | 56px circle (size-14), navy, 26px stream glyph, --shadow-16, scales 105% on hover |
| Message bubble | max-width 75%, rounded-xl squared towards the avatar, 14px text; AI on navy, user on --accent |
| Avatar | 32px (size-8); stream glyph for the AI, initials from author for the user |
| Citation card | --card surface, 1px border, rounded-lg, max-width 24rem, 14px menu_book glyph |
| Composer | rounded-xl bordered --background, --shadow-1; focus-within ring 2px --ring at 40%; textarea grows to 128px |
Best practices
Do
- Mark every piece of generated content —
AIMessage role2="ai"carries the badge itself; useAIBadgewherever AI output appears outside the conversation. - Ground answers with
AICitationCard— an assistant that cites its source earns the trust the palette claims. - Seed the composer with
suggestionsso the first prompt is one click, not a blank box. - Pass
disabledto the composer while a response is pending — it already disables send on an empty draft. - Keep entry points to one per screen:
AskAIButtonin a toolbar, or the FAB — not both.
Don't
- Use the reserved palette (
--brand-navy/--brand-stream) on anything outside this family — it is the visual promise that "this is the assistant". - Present AI output as if a person wrote it — no unbadged bubbles.
- Remove the FAB's accessible name; it is icon-only and ships with
aria-label="Open assistant". - Put the FAB over content it obscures — it is
fixedbottom-right atz-50.
Accessibility & keyboard
- Every icon-only control ships named: the FAB defaults to
aria-label="Open assistant"(overridable), the composer's textarea is labelled "Prompt", send is "Send prompt" and attach is "Attach a file". - The send button is
disabledwhile the draft is empty, so it is never an actionable dead end. AICitationCardis a real anchor with a visible focus ring; suggestion chips are real buttons.AIMessage's variant prop is namedrole2precisely so it cannot clobber the ARIAroleattribute.- The suite ships no live region:
AIMessagerenders plaindivs, so responses injected after load are not announced by anything here — the surface that streams messages in owns that announcement. - Keyboard: the binding is stated below the composer with
Kbd. In the composer, Enter sends and Shift+Enter inserts a newline; Tab moves chips → attach → textarea → send. Chips fill the draft, they do not submit. The textarea deliberately carries noaria-keyshortcuts— that attribute advertises a shortcut which activates or focuses an element, whereas these are the textarea's own editing behaviour once it already has focus.
Props
AIBadge and AskAIButton are a styled native <span> and <button> — every native
attribute, plus children to replace the default "AI" / "Ask AI" text. The rest:
AssistantFAB
| Prop | Type | Default | Description |
|---|---|---|---|
floating | boolean | undefined | true | Pin to the bottom-right of the viewport. Disable to render in flow (e.g. documentation previews). |
AIMessage
| Prop | Type | Default | Description |
|---|---|---|---|
role2 | "ai" | "user" | undefined | — | Bubble role (Figma variant): sets alignment, avatar and colour. |
author | string | undefined | "You" | Author name for the avatar fallback (user role). |
AICitationCard
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | undefined | — | — |
sourceTitlerequired | string | — | Source title, e.g. the document or policy name. |
snippet | string | undefined | — | Short quoted snippet grounding the answer. |
origin | string | undefined | — | Origin label, e.g. "HealthMetrics Handbook". |
AIPromptComposer
| Prop | Type | Default | Description |
|---|---|---|---|
suggestions | string[] | undefined | — | Quick suggestion chips shown above the input. |
onSend | ((prompt: string) => void) | undefined | — | Called with the submitted prompt text. |
onAttach | (() => void) | undefined | — | Called when the attach affordance is used; hidden when omitted. |
placeholder | string | undefined | — | — |
disabled | boolean | undefined | — | — |
Live controls for every part in Storybook → UI → AI.