Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Chat Message

    Message in an AI conversation. User bubbles on the right, assistant replies with an avatar, hover actions, a typing indicator, and optional token streaming.

    Can you draft an invoice in Rupiah for a website project?

    Markas AI

    Sure. Here is a simple layout for it: Design and build, Rp 12.500.000 VAT 11%, Rp 1.375.000 Total due, Rp 13.875.000
    Add a 14 day payment term, please.

    Markas AI

    Typing
    Can you draft an invoice in Rupiah for a website project?

    Markas AI

    Sure. Here is a simple layout for it: Design and build, Rp 12.500.000 VAT 11%, Rp 1.375.000 Total due, Rp 13.875.000
    Add a 14 day payment term, please.

    Markas AI

    Typing
    Can you draft an invoice in Rupiah for a website project?

    Markas AI

    Sure. Here is a simple layout for it: Design and build, Rp 12.500.000 VAT 11%, Rp 1.375.000 Total due, Rp 13.875.000
    Add a 14 day payment term, please.

    Markas AI

    Typing
    Can you draft an invoice in Rupiah for a website project?

    Markas AI

    Sure. Here is a simple layout for it: Design and build, Rp 12.500.000 VAT 11%, Rp 1.375.000 Total due, Rp 13.875.000
    Add a 14 day payment term, please.

    Markas AI

    Typing
    Can you draft an invoice in Rupiah for a website project?

    Markas AI

    Sure. Here is a simple layout for it: Design and build, Rp 12.500.000 VAT 11%, Rp 1.375.000 Total due, Rp 13.875.000
    Add a 14 day payment term, please.

    Markas AI

    Typing
    @php
        $log = 'grid gap-4';
        $answer = "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    @endphp
    
    <div role="log" aria-label="Conversation" class="{{ $log }}">
        <x-markas.chat-message from="user" text="Can you draft an invoice in Rupiah for a website project?" time="10:24" />
        <x-markas.chat-message :text="$answer" time="10:24" assistant-label="Markas AI" />
        <x-markas.chat-message from="user" text="Add a 14 day payment term, please." time="10:25" />
        <x-markas.chat-message typing assistant-label="Markas AI" />
    </div>
    import { ChatMessage } from "@/components/markas/ChatMessage";
    
    const log = "grid gap-4";
    const answer =
      "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    
    export default function ChatMessageExample() {
      return (
        <div role="log" aria-label="Conversation" className={log}>
          <ChatMessage
            from="user"
            text="Can you draft an invoice in Rupiah for a website project?"
            time="10:24"
          />
          <ChatMessage text={answer} time="10:24" assistantLabel="Markas AI" />
          <ChatMessage
            from="user"
            text="Add a 14 day payment term, please."
            time="10:25"
          />
          <ChatMessage typing assistantLabel="Markas AI" />
        </div>
      );
    }
    <script setup lang="ts">
    import ChatMessage from "@/components/markas/ChatMessage.vue";
    
    const log = "grid gap-4";
    const answer =
      "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    </script>
    
    <template>
      <div role="log" aria-label="Conversation" :class="log">
        <ChatMessage
          from="user"
          text="Can you draft an invoice in Rupiah for a website project?"
          time="10:24"
        />
        <ChatMessage :text="answer" time="10:24" assistant-label="Markas AI" />
        <ChatMessage
          from="user"
          text="Add a 14 day payment term, please."
          time="10:25"
        />
        <ChatMessage typing assistant-label="Markas AI" />
      </div>
    </template>
    <script lang="ts">
      import ChatMessage from "$lib/components/markas/ChatMessage.svelte";
    
      const log = "grid gap-4";
      const answer =
        "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    </script>
    
    <div role="log" aria-label="Conversation" class={log}>
      <ChatMessage
        from="user"
        text="Can you draft an invoice in Rupiah for a website project?"
        time="10:24"
      />
      <ChatMessage text={answer} time="10:24" assistantLabel="Markas AI" />
      <ChatMessage
        from="user"
        text="Add a 14 day payment term, please."
        time="10:25"
      />
      <ChatMessage typing assistantLabel="Markas AI" />
    </div>
    ---
    import ChatMessage from "@/components/markas/ChatMessage.astro";
    
    const log = "grid gap-4";
    const answer =
      "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    ---
    
    <div role="log" aria-label="Conversation" class={log}>
      <ChatMessage
        from="user"
        text="Can you draft an invoice in Rupiah for a website project?"
        time="10:24"
      />
      <ChatMessage text={answer} time="10:24" assistantLabel="Markas AI" />
      <ChatMessage
        from="user"
        text="Add a 14 day payment term, please."
        time="10:25"
      />
      <ChatMessage typing assistantLabel="Markas AI" />
    </div>
    import { Component } from "@angular/core";
    import { ChatMessage } from "./markas/chat-message.component";
    
    @Component({
      selector: "markas-example",
      imports: [ChatMessage],
      template: `
        <div role="log" aria-label="Conversation" [class]="log">
          <markas-chat-message
            from="user"
            text="Can you draft an invoice in Rupiah for a website project?"
            time="10:24"
          />
          <markas-chat-message
            [text]="answer"
            time="10:24"
            assistantLabel="Markas AI"
          />
          <markas-chat-message
            from="user"
            text="Add a 14 day payment term, please."
            time="10:25"
          />
          <markas-chat-message typing assistantLabel="Markas AI" />
        </div>
      `,
    })
    export default class ChatMessageExample {
      protected readonly log = "grid gap-4";
      protected readonly answer =
        "Sure. Here is a simple layout for it:\nDesign and build, Rp 12.500.000\nVAT 11%, Rp 1.375.000\nTotal due, Rp 13.875.000";
    }

    Examples

    Support chat with bubbles

    My invoice shows Rp 0 for shipping. Is that right?

    Support bot

    Yes. Orders above Rp 500.000 ship for free, so the shipping line stays at Rp 0.
    My invoice shows Rp 0 for shipping. Is that right?

    Support bot

    Yes. Orders above Rp 500.000 ship for free, so the shipping line stays at Rp 0.
    My invoice shows Rp 0 for shipping. Is that right?

    Support bot

    Yes. Orders above Rp 500.000 ship for free, so the shipping line stays at Rp 0.
    My invoice shows Rp 0 for shipping. Is that right?

    Support bot

    Yes. Orders above Rp 500.000 ship for free, so the shipping line stays at Rp 0.
    My invoice shows Rp 0 for shipping. Is that right?

    Support bot

    Yes. Orders above Rp 500.000 ship for free, so the shipping line stays at Rp 0.

    Streaming answer

    When is VAT due for my October invoices?

    Markas AI

    VAT for October is due by the end of November. Report it in your monthly return and pay before you file, so the payment code is already on record.
    When is VAT due for my October invoices?

    Markas AI

    VAT for October is due by the end of November. Report it in your monthly return and pay before you file, so the payment code is already on record.
    When is VAT due for my October invoices?

    Markas AI

    VAT for October is due by the end of November. Report it in your monthly return and pay before you file, so the payment code is already on record.
    When is VAT due for my October invoices?

    Markas AI

    VAT for October is due by the end of November. Report it in your monthly return and pay before you file, so the payment code is already on record.
    When is VAT due for my October invoices?

    Markas AI

    VAT for October is due by the end of November. Report it in your monthly return and pay before you file, so the payment code is already on record.

    Read-only transcript

    Please resend invoice INV-2041.

    Markas AI

    Done. A fresh copy went to finance@sinarjaya.co.id.
    Thanks, received it.
    Please resend invoice INV-2041.

    Markas AI

    Done. A fresh copy went to finance@sinarjaya.co.id.
    Thanks, received it.
    Please resend invoice INV-2041.

    Markas AI

    Done. A fresh copy went to finance@sinarjaya.co.id.
    Thanks, received it.
    Please resend invoice INV-2041.

    Markas AI

    Done. A fresh copy went to finance@sinarjaya.co.id.
    Thanks, received it.
    Please resend invoice INV-2041.

    Markas AI

    Done. A fresh copy went to finance@sinarjaya.co.id.
    Thanks, received it.

    Installation

    npx markasui@latest add chat-message

    Usage

    <div role="log" aria-label="Conversation" class="grid gap-5">
        <x-markas.chat-message from="user" text="How do I bill a client in Rupiah?" time="10:24" />
        <x-markas.chat-message
            text="Set the currency to IDR and list each item with its amount."
            time="10:24"
            assistant-label="Markas AI"
            x-on:feedback="rate($event.detail)"
            x-on:regenerate="retry()"
        />
        <x-markas.chat-message typing assistant-label="Markas AI" />
    </div>
    import { ChatMessage } from "@/components/markas/ChatMessage";
    
    <div role="log" aria-label="Conversation" className="grid gap-5">
      <ChatMessage
        from="user"
        text="How do I bill a client in Rupiah?"
        time="10:24"
      />
      <ChatMessage
        text={answer}
        time="10:24"
        assistantLabel="Markas AI"
        stream
        onFeedback={rate}
        onRegenerate={retry}
      />
    </div>;
    <script setup lang="ts">
    import ChatMessage from "@/components/markas/ChatMessage.vue";
    </script>
    
    <template>
      <div role="log" aria-label="Conversation" class="grid gap-5">
        <ChatMessage
          from="user"
          text="How do I bill a client in Rupiah?"
          time="10:24"
        />
        <ChatMessage
          :text="answer"
          assistant-label="Markas AI"
          variant="bubble"
          @feedback="rate"
          @regenerate="retry"
        />
      </div>
    </template>
    <script lang="ts">
      import ChatMessage from "$lib/components/markas/ChatMessage.svelte";
    </script>
    
    <div role="log" aria-label="Conversation" class="grid gap-5">
      <ChatMessage
        from="user"
        text="How do I bill a client in Rupiah?"
        time="10:24"
      />
      <ChatMessage
        text={answer}
        time="10:24"
        assistantLabel="Markas AI"
        stream
        onFeedback={rate}
        onRegenerate={retry}
      />
    </div>
    ---
    import ChatMessage from "@/components/markas/ChatMessage.astro";
    ---
    
    <div role="log" aria-label="Conversation" class="grid gap-5">
      <ChatMessage from="user" text="How do I bill a client in Rupiah?" time="10:24" />
      <ChatMessage text={answer} time="10:24" assistantLabel="Markas AI" stream />
    </div>

    A small custom element streams the text, copies it, and toggles the rating. It dispatches markas-feedback (the new value as detail) and markas-regenerate, both bubbling.

    import { Component } from "@angular/core";
    import { ChatMessage } from "./markas/chat-message.component";
    
    @Component({
      selector: "app-conversation",
      imports: [ChatMessage],
      template: `
        <div role="log" aria-label="Conversation" class="grid gap-5">
          <markas-chat-message
            from="user"
            text="How do I bill a client in Rupiah?"
          />
          <markas-chat-message
            [text]="answer"
            assistantLabel="Markas AI"
            stream
            (feedback)="rate($event)"
            (regenerate)="retry()"
          />
        </div>
      `,
    })
    export class Conversation {
      answer = "Add the amount in Rupiah and a payment term.";
      rate(value: "like" | "dislike" | null) {}
      retry() {}
    }
    • The action row fades in when the pointer is over the message or focus is inside it, so it never clutters the conversation.
    • Copy shows a check for two seconds. Like and dislike are exclusive toggles and fire feedback with the new value.
    • stream reveals the text one word at a time with a caret. If text grows while streaming, the reveal carries on to the new end.
    • Reduced motion turns off the streaming, the dots pulse, and the fades.

    Props

    NameTypeDefaultDescription
    from"user" | "assistant"assistantWho wrote it. User messages are a primary bubble on the right, assistant messages sit on the left with an avatar.
    textstring""Message text. Line breaks are kept. Copy writes this text to the clipboard.
    variant"plain" | "bubble"plainAssistant style: plain text, or a soft subtle bubble.
    timestring-Timestamp shown in a time element, next to the name for the assistant and under the bubble for the user.
    avatarstring-Image URL for the assistant avatar. Without it a spark icon is shown.
    typingbooleanfalseShows three pulsing dots in place of the text, announced as typingLabel.
    streambooleanfalseReveals the text token by token with a caret, like a model streaming. With reduced motion the full text shows at once.
    streamSpeednumber40Pause between streamed tokens in ms.
    actionsbooleantrueShows the action row on hover and focus: copy, plus like, dislike, and regenerate for the assistant. Hidden while typing or streaming.
    onFeedback / @feedback / x-on:feedback(value: "like" | "dislike" | null) => void-Fires when like or dislike is toggled. Pressing the active one again sends null.
    onRegenerate / @regenerate / x-on:regenerate() => void-Fires when the regenerate button is pressed.
    userLabelstringYouAccessible name of user messages.
    assistantLabelstringAssistantName shown above assistant messages and their accessible name, such as the product name.
    typingLabelstringTypingHidden status text while typing is on.
    actionsLabelstringMessage actionsAccessible name of the action group.
    copyLabelstringCopyAccessible name of the copy button.
    copiedLabelstringCopiedStatus announced after copying.
    likeLabelstringGood responseAccessible name of the like button.
    dislikeLabelstringBad responseAccessible name of the dislike button.
    regenerateLabelstringRegenerateAccessible name of the regenerate button.
    (feedback) / (regenerate)output-Angular only. Emits the new rating (like, dislike, or null) and a press of regenerate. Svelte uses onFeedback and onRegenerate like React.
    markas-feedback / markas-regenerateCustomEvent-Astro only. Bubbling events from markas-chat-message, with the new rating as detail for feedback.

    Accessibility

    • Each message is an article named by userLabel or assistantLabel. Put the messages inside an element with role="log" so new ones are announced.
    • The actions fade in on hover and on keyboard focus inside the message, and stay visible on touch screens. Like and dislike are toggle buttons with aria-pressed.
    • Copying announces copiedLabel through a status region. The typing dots are hidden and announced as typingLabel.
    • While streaming, screen readers get the full text at once from a hidden copy. Reduced motion skips the streaming and the pulsing.

    Related components

    More markasui components with the same classes in every framework.