aiellie

Search

Find a component, template or page

GitHub
Components

Quoted Message

The words a reply is about, kept to a short excerpt above it behind a rule on the start side, with who said them and a way to remove the quote.

Does that work inside a flex row?
AssistantSet the parent as a container, then style its children by the parent's width rather than the window's.
Open full screen
fig. 01 · open it full screen from the corner

Installation

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

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

Quoted Message keeps the words a reply is about above it: a short excerpt behind a rule on the start side, with who said them. Above a message it can lead back to the original; in a composer it says what the message being written answers, and can be taken off again.

Getting started

  1. Quote above a message

    Render the content as a button or link when it should lead back to what it quotes.

    components/reply-with-quote.tsx
    import {
      QuotedMessage,
      QuotedMessageContent,
      QuotedMessageText,
    } from "@/components/aiellie/quoted-message"
    
    export function ReplyQuote({ text, onJump }: { text: string; onJump: () => void }) {
      return (
        <QuotedMessage>
          <QuotedMessageContent render={<button type="button" onClick={onJump} />} lines={1}>
            <QuotedMessageText>{text}</QuotedMessageText>
          </QuotedMessageContent>
        </QuotedMessage>
      )
    }

Anatomy

<div data-slot="quoted-message">
  <div data-slot="quoted-message-content"> {/* or a button or link */}
    <span data-slot="quoted-message-author" />
    <span data-slot="quoted-message-text" />
  </div>
  <button data-slot="quoted-message-dismiss" />
</div>

The excerpt is cut after lines lines, two by default, so a long quote never pushes the reply down. The quote is in muted-foreground, set apart from the words that answer it by the rule and the ink rather than by a box.

Content rendered as a button or link takes the ring colour on its border when focused, and foreground on hover.

Examples

In the composer

Put the quote at the top of the composer with a way to take it off, and clear it once the message is sent.

Replying to AssistantSet the parent as a container, then style its children by its width.

API reference

QuotedMessageContent

PropTypeDefaultDescription
lines1 | 2 | 32How many lines of the excerpt show before it's cut.
renderReactElementRenders it as another element, like a button or link.

All other div props are forwarded.

QuotedMessageDismiss

PropTypeDefaultDescription
tooltipstring"Remove quote"Its name.

All other TooltipIconButton props are forwarded.

QuotedMessage, QuotedMessageAuthor, QuotedMessageText

PropTypeDefaultDescription
classNamestringMerged onto the element.

All other props of their element are forwarded.