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.
Also 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.
When to use
Anatomy
MessageEmbed: the card, onlayer-cardwith aline-hairlineborder andradius-container.sizegives 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-containerless 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 aninteractivecard it takes the card's hover and press tier on top, and it takes no pointer (Behavior). Put it inMessageEmbedContentwhen 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, keepsinteractiveoff: it opens nothing as a whole, so it doesn't hover. - Wrap each opaque picture in an
interactivecard inMessageEmbedCover, 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 theMessageEmbedCoveritself: 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 itpointer-events-auto. - A card rendered as a link shows the focus ring on keyboard focus (States).
- The card never clips what it holds: only
MessageEmbedContentat 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 aclassNameonMessageEmbedContentdoesn't undo them.
Accessibility
MessageEmbedand its parts are plaindivelements built with Base UIuseRender; userenderto change the element.- When the whole card opens something, render
MessageEmbedas 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:itemfor a card that opens one thing (at most 400px, the message's width on a phone),contentfor 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-uibeside 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
Also takes the attributes of its element.
MessageEmbedContent, MessageEmbedCover, MessageEmbedFooter, MessageEmbedHeader
Also takes the attributes of its element.
Related
Changes
- 0.84.0 · Added
messageCardandmessageEmbed, 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()givessource(withsourceIcon,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) andpopover;messageEmbed({ size })the frame and its widths, whichMessageEmbed sizeapplies. - 0.84.0 · FixedA cover or an excerpt no longer cuts off a card's corners:
MessageEmbedContentthat is the card's first or last part takes the card's inner corner,radius-containerless 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 onMessageEmbeddon't change.