Raft Design System

Components · Messages

MessageEmbed

The card that embedded message content is built on — a header, content and footer in a hairline card — used for link cards and as the base of forwarded bundles, action cards and reply summaries.

StableAlso called Link card, Embed
import { MessageEmbed } from "@botiverse/raft-ui";

The card for something embedded in a message: a link card, or the base that other embedded cards build on. It is the frame every card in a message shares (Cards in messages), and sits in MessageItemEmbedded, under the message body. MessageForwardedBundle, MessageActionCard and AppLinkCard render on it, and MessageReplies uses its container.

message-embed/compositions/link-cards

When to use

SituationUse
A link an app previews (a pull request, a document)A reference chip in the text, not a card (MessageItem)
A link to a page, previewed under the messageMessageEmbed, as a link card
Messages passed on from another conversationMessageForwardedBundle
A link to one message, shown as an excerptMessageQuotedPreview
An agent needs a person's approvalMessageActionCard
A file, an image or a videoMessageAttachment
The replies to a messageMessageReplies
Code, a diagram or a Markdown tableCodeBlock
A new kind of embedded cardMessageEmbed as its base, not a new container (Built from existing parts)

Anatomy

  • MessageEmbed: the card, on layer-card with a line-hairline border and radius-container. size gives it an item card's or a content card's width (Two widths). Required.
  • MessageEmbedHeader: the top row, with its own padding. Holds what the card is and where it comes from.
  • MessageEmbedContent: the body. It has no padding of its own: the content inside sets it, so an image or a list of items can run to the card's edges. As the card's first or last part, it takes the card's inner corner, radius-container less the 1px border, on the two corners it shares with the card, and clips what it holds to them: a cover at the top is round at the top and square at its foot. Square, a cover or an excerpt would cover the border's arc, and the card would look cut at those corners (Inside a frame). A frame restyled as a square bar, as MessageQuotedPreview's is, has no corner to follow: its content stays square and clips nothing.
  • MessageEmbedCover: a picture in the card, such as a screenshot, a cover image or a page's first lines drawn as one. On an interactive card it takes the card's hover and press tier on top, and it takes no pointer (Behavior). Put it in MessageEmbedContent when it is the card's first or last part, so it takes the card's inner corner; between two rows it stays square.
  • MessageEmbedFooter: the bottom row, padded like the header. Holds the card's actions.

Only MessageEmbed is required; use the parts the content needs.

Behavior

  • The card and its parts can shrink below the width of their content, so long content wraps or truncates inside the card instead of widening the message.
  • A card that opens something as a whole, such as an Artifact card whose title link covers it, takes interactive: it hovers with the subtle tier and presses with the medium tier, like a file card (MessageAttachment, Hover and press). The hover tells a card that opens from one that doesn't. A card that only shows content, such as an action card or a forwarded bundle, keeps interactive off: it opens nothing as a whole, so it doesn't hover.
  • Wrap each opaque picture in an interactive card in MessageEmbedCover, and nothing else: the card's tier is its background and a picture hides it, so the cover takes the same tier on top and the whole card steps together (Media in a pressable card). Keep the picture in flow, and put a mask, an opacity or a transform on the MessageEmbedCover itself: a picture that is positioned or makes a stacking context of its own paints over the tier. The cover takes no pointer, so a click on it reaches the title link that covers the card; give a control laid on it pointer-events-auto.
  • A card rendered as a link shows the focus ring on keyboard focus (States).
  • The card never clips what it holds: only MessageEmbedContent at its top or bottom does. A title link that covers the card (its ::after) draws its focus ring around the whole card, outside the frame, and a card that clipped would cut it off. Something focusable inside an edge part that reaches the card's edge has its ring cut there, so draw that ring inside the element (Inside a frame). The card sets the corner and the clip on the part, so a className on MessageEmbedContent doesn't undo them.

Accessibility

  • MessageEmbed and its parts are plain div elements built with Base UI useRender; use render to change the element.
  • When the whole card opens something, render MessageEmbed as an <a> and give it an accessible name that says what opens.
  • Don't put a button inside a card rendered as a link: each control must be its own element, as in MessageAttachment.

Rules

  • Build every embedded card on MessageEmbed, without new colors, shapes or lines (Built from existing parts).
  • Give the card one of the two widths with size: item for a card that opens one thing (at most 400px, the message's width on a phone), content for a card that shows other messages (at most 560px). Never give it a width of its own (max-w-[440px], max-w-md).
  • Take the inset, the source row, the title, the details and the buttons from messageCard, exported from @botiverse/raft-ui beside MessageEmbed (messageCard().title(), messageCard().meta(), messageCard().actions()), never classes of the card's own: every card in a message and every item popover is drawn from these two, so they change together (Cards in messages). A card that is an app's link card can use AppLinkCard's parts instead, which are drawn from it.
  • A card that shows a preview of what it opens, such as an Artifact card, puts its details in messageCard().metaLine(); its order and what it shows follow A card with a preview.
  • Put the card in MessageItemEmbedded, after the body and the attachments.

API

MessageEmbed

PropTypeDefault
interactiveThe whole card opens something (a link or a button in it covers the card): it hovers with the subtle tier and presses with the medium tier, like a file card, over each MessageEmbedCover in it too. Off for a card that only shows content.booleanfalse
sizeThe card's width, one of the two a card in a message has (cards-in-messages.md): `item` for a card that opens one thing, at most 400px and the message's width on a phone; `content` for a card that shows other messages, at most 560px. Unset, the card sets no width."content" | "item"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

MessageEmbedContent, MessageEmbedCover, MessageEmbedFooter, MessageEmbedHeader

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

Changes

  • 0.84.0 · AddedmessageCard and messageEmbed, from @botiverse/raft-ui: the recipes every card in a message is drawn from, so an app's own card takes the same parts. messageCard() gives source (with sourceIcon, sourceName, sourceHost, sourceHostText), sourceFooter, body, eyebrow, title, heading, meta, actions, actionRow, inset, actionGroup (the buttons as one item of a row that also holds a status line) and popover; messageEmbed({ size }) the frame and its widths, which MessageEmbed size applies.
  • 0.84.0 · FixedA cover or an excerpt no longer cuts off a card's corners: MessageEmbedContent that is the card's first or last part takes the card's inner corner, radius-container less the 1px border, on the two corners it shares with the card, and clips what it holds to them (overflow: clip). A cover at the top is round at the top and square at its foot. The card itself still clips nothing, so a title link's focus ring around the whole card (its ::after) still shows.
  • 0.55.0 · AddedMessageEmbed interactive: a card that opens something as a whole (an Artifact card whose title link covers it) hovers with the subtle tier and presses with the medium tier, like a file card. Off by default, so action cards, forwarded bundles and quoted previews built on MessageEmbed don't change.