Message

One turn: the person's message, and the agent's reply with its actions.

Usage

Message

How do I add a settings dialog? It should open from the gear icon in the header.

Install Dialog, then open it from the gear button in site-header.ts.

ng add @semantic-components/ui

Put scDialogTrigger on the button and the settings form in the dialog. Focus moves into the dialog when it opens, and Escape closes it.

import { NgTemplateOutlet } from '@angular/common';import {  Component,  DestroyRef,  ViewEncapsulation,  inject,  signal,} from '@angular/core';import {  ScBubble,

The person's text is a Bubble on a Message aligned to the end; the agent's reply is text on a Message, with actions under it. A thread of these turns is Chat.

Anatomy

import {  ScMessage, ScMessageContent, ScMessageFooter,  ScBubble, ScBubbleContent, ScButton,} from '@semantic-components/ui';
<div scMessage alignment="end">  <div scMessageContent>    <div scBubble alignment="end" variant="muted">      <div scBubbleContent>How do I add a settings dialog?</div>    </div>  </div></div><div scMessage>  <div scMessageContent class="gap-2">    <p>Install Dialog, then open it from the gear button.</p>    <div scMessageFooter>      <button scButton variant="ghost" size="icon-sm">        <svg siCopyIcon></svg>        <span class="sr-only">Copy</span>      </button>    </div>  </div></div>

Actions

Actions go in the message's footer, which follows its alignment: on the person's turn they sit at the end. Ghost icon buttons, each named by hidden text and shown in a tooltip.

  • Copy writes the reply to the clipboard and turns to a check for two seconds; its name follows: Copy, then Copied.
  • Good response and Bad response are toggles: a fixed name, the state in aria-pressed.
  • Retry runs the turn again.
  • Edit, on the person's turn, puts the text back in the field.

Markdown

The reply streams as markdown. The library has no Markdown renderer yet: here the reply is written out, its code in a Code Block.

Examples

RTL

كيف أضيف نافذة للإعدادات؟

ثبّت مكوّن النافذة، ثم افتحها من زر الترس في رأس الصفحة. ينتقل التركيز إلى النافذة عند فتحها، ويغلقها زر Esc.

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScButton,  ScMessage,  ScMessageContent,  ScMessageFooter,} from '@semantic-components/ui';

API reference

See the Message, the Bubble and the Tooltip.