aiellie

Search

Find a component, template or page

GitHub
Components

Message Status

How far a message has got: sending, sent, delivered, read, or not sent with a retry.

Running five minutes late
Sending
Start without me
Not sent
Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/message-status"

shadcn needs the @aiellie registry in components.json first. npx aiellie add message-status adds it on its first run, then installs the same way.

Message Status shows how far a message has got: a clock while sending, a tick once sent, a double tick when delivered, the same double tick in full ink once read, and a warning when it couldn't be sent. A failed message can offer "Try again".

It's an icon with its name kept for screen readers, or shown with showLabel.

Getting started

  1. Put it under the message

    components/sent-message.tsx
    import {
      Message,
      MessageContent,
      MessageFooter,
      MessagePart,
    } from "@/components/aiellie/message"
    import {
      MessageStatus,
      type MessageStatusValue,
    } from "@/components/aiellie/message-status"
    
    export function SentMessage({
      text,
      status,
      onRetry,
    }: {
      text: string
      status: MessageStatusValue
      onRetry: () => void
    }) {
      return (
        <Message align="end">
          <MessageContent>
            <MessagePart>{text}</MessagePart>
            <MessageFooter>
              <MessageStatus status={status} onRetry={onRetry} />
            </MessageFooter>
          </MessageContent>
        </Message>
      )
    }

Anatomy

<span data-slot="message-status" data-status="read" role="status">
  <svg />
  <span /> {/* the label, screen readers only unless showLabel */}
  <button /> {/* Try again, when failed */}
</span>

It's a status region, so the new state is read out without interrupting. The clock pulses while sending, except under reduced motion.

Examples

Your words

labels renames any of the states.

Seen by AdaOffline

API reference

MessageStatus

PropTypeDefaultDescription
status"sending" | "sent" | "delivered" | "read" | "failed"required
showLabelbooleanfalseShows the name beside the icon.
labelsPartial<Record<status, string>>Your own names.
onRetry() => voidAdds "Try again" when failed.

All other span props are forwarded.