Design System
Patterns

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:

  1. AIBadge — marks AI-generated content, in or out of the conversation.
  2. AskAIButton — the primary entry point; a deep-gradient button with the stream glyph.
  3. AssistantFAB — floating launcher, pinned bottom-right (floating={false} for in-flow).
  4. AIMessage — the conversation bubble; role2="ai" | "user" sets alignment, avatar and colour.
  5. AICitationCard — grounds an answer in a source; a linked card with title, snippet and origin.
  6. 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.

AR

What is my remaining dental entitlement this year?

AI

Your dental entitlement is MYR 500 per policy year. You have used MYR 180, so MYR 320 remains until 31 December 2026.

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 AI

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

Wired into a conversation
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.

PropertyValue
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
Badge11px semibold, navy fill, stream text, rounded-sm, 12px auto_awesome glyph
Ask AI button40px tall (h-10), navy fill, white text, 18px stream glyph, --shadow-2
FAB56px circle (size-14), navy, 26px stream glyph, --shadow-16, scales 105% on hover
Message bubblemax-width 75%, rounded-xl squared towards the avatar, 14px text; AI on navy, user on --accent
Avatar32px (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
Composerrounded-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; use AIBadge wherever 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 suggestions so the first prompt is one click, not a blank box.
  • Pass disabled to the composer while a response is pending — it already disables send on an empty draft.
  • Keep entry points to one per screen: AskAIButton in 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 fixed bottom-right at z-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 disabled while the draft is empty, so it is never an actionable dead end.
  • AICitationCard is a real anchor with a visible focus ring; suggestion chips are real buttons.
  • AIMessage's variant prop is named role2 precisely so it cannot clobber the ARIA role attribute.
  • The suite ships no live region: AIMessage renders plain divs, 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 no aria-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

PropTypeDefaultDescription
floatingboolean | undefinedtruePin to the bottom-right of the viewport. Disable to render in flow (e.g. documentation previews).

AIMessage

PropTypeDefaultDescription
role2"ai" | "user" | undefined—Bubble role (Figma variant): sets alignment, avatar and colour.
authorstring | undefined"You"Author name for the avatar fallback (user role).

AICitationCard

PropTypeDefaultDescription
hrefstring | undefined——
sourceTitlerequiredstring—Source title, e.g. the document or policy name.
snippetstring | undefined—Short quoted snippet grounding the answer.
originstring | undefined—Origin label, e.g. "HealthMetrics Handbook".

AIPromptComposer

PropTypeDefaultDescription
suggestionsstring[] | 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.
placeholderstring | undefined——
disabledboolean | undefined——

Live controls for every part in Storybook → UI → AI.

On this page