Components · Overlays
PreviewCard
The read-only card that appears when people hover over or focus a mention, a name or an app link, showing who someone is or what an app's item is, with up to two small buttons.
import { PreviewCard } from "@botiverse/raft-ui";A preview card is the read-only card that appears when people hover over or focus something in the text, so they can see what it is without leaving the conversation. It has two uses: the profile card of a person or an agent, on a mention or a name such as @Bugen, with the avatar, the name and a status line; and the item card of an app link, such as a pull request a message links to, with its title and the details the app supplies. Either holds up to two small buttons. Raft Chat's profile card has no buttons (Raft Chat).
When to use
Which overlay fits which job is in Choosing a component.
Anatomy
PreviewCard: the root. Required.PreviewCardTrigger: the mention, name or chip that opens the card, usually a link to what it names. Required.PreviewCardContent: the card, portaled and positioned under the trigger: 300px wide for a profile, and 400px withsize="item"for an item card, which has a title, a state and buttons to fit. Choose by what the card shows, not by its parts: a card that shows an item (its title, with a state or details) issize="item"; a card that asks for one step, such as connecting an account, keeps the default 300px, even when it usesPreviewCardBodyfor its sentence; it then takes the body's 12px inset and its title the card title's size, like the item card it leads to. Required.PreviewCardHeader: the large Avatar and, beside it, the name and the line under it.PreviewCardTitle: the name, on one line; inPreviewCardBody, an item's title, the title of a card in a message, which wraps.PreviewCardSeparator: the hairline under the header.PreviewCardSubtitle: the status line, data about the subject, one line, truncated. It wasPreviewCardDescription.PreviewCardArrow: an optional pointer toward the trigger, on whichever side the card opens, likePopoverArrow. The card clips what overflows it, so a card with an arrow lets it overflow (overflow-visible).PreviewCardPortalandPreviewCardPopup: lower-level parts.PreviewCardPopupis the card surface without positioning.
The item card adds these parts, experimental and exported from @botiverse/raft-ui/wip until the design is approved:
PreviewCardBody: the block with the id line, the title and the details row, 12px from the card's edges. The card is a column of its parts capped at the room it has (--available-height); past that the body scrolls, faded at its cut edges, while the header, the actions and the footer keep their height, as PopoverBody does. Its parts, the actions and the footer are a card's in a message (Cards in messages), so the hover card and the block card (AppLinkCard) stay alike.PreviewCardEyebrow: the id line above the title, inforeground-mutedSpace Mono, one line, truncated.PreviewCardMeta: the row under the title: the state, in a neutral Badge or in the app's color when it sends one, then a muted line of details. It wraps when it runs out of room.PreviewCardActions: one row of up to two buttons at the card's end, 12px from its edges as in a card in a message: the confirm button last. A third action goes in a More menu (⋯) the app's card supplies; a status line beside the buttons wraps onto its own line before they do (Buttons).PreviewCardFooter: a caption under a hairline at the bottom: the app and the host.
Item card
The card an app link opens on hover (App links). The app supplies its words and which details it has; Raft sets their order and their colors. Its parts follow the questions a reader asks, in order:
- Which item is it?
PreviewCardEyebrow: the app's id for it, such asbotiverse/slock#10449. Optional. - What is it about?
PreviewCardTitle: the app's title in ink, up to 2 lines, cut off with an ellipsis; only when it is cut off, the app wraps it in a Tooltip that shows it whole on hover (not a nativetitle);PreviewCardTitledoesn't add one itself. Always in ink, not inforeground-link. On desktop and phone web the card is not a link itself, its buttons and the chip are; in the iOS and Android apps the title opens the item, because there the card covers the chip (App links). - Where does it stand?
PreviewCardMeta: one state chip in the app's words, such as Merged, in the app's color when it sends one, then one muted line of details, such as "Martin · +803 −498". Separate the details on one line with "·", but put none next to the state chip: the chip is set apart by its own fill. - What can I do?
PreviewCardActions: up to two buttons the app provides, on one line at the card's end:- The app's action buttons (Approve), the first two in the app's order. With none, the first link (Open in Stamp ↗) takes the row instead. In the iOS and Android apps, where the title opens the item, the link to the item goes in ⋯ and never takes the row (App links).
- Frameless buttons first, the bordered one last, at the right end.
- Everything else, such as Refresh, further links and any further action, goes in a More menu (⋯) to the left of them, in the app's order, never wrapped onto a second line and never dropped. A link in the menu is a link item with the leaving mark (↗). The menu opens aligned to its button's end (
align="end"), so it stays over the card. - While one of the app's actions runs, the row's buttons and the menu's items are disabled; the More button stays enabled, so people can still see what is in it. A status line with a Spinner says so, placed beside the buttons as in Cards in messages. Raft writes it, not the app, and in words that aren't a task status: "Working…", never In progress, since nothing on an item card carries a task's meaning (Rules). A menu item the app has disabled shows the app's reason as its second line, since a menu item has no tooltip (DropdownMenu).
- An action that asks to be confirmed opens a Dialog at
size="sm"outside the card: a hover card closes when the pointer leaves it, so the confirmation can't live inside it. What the confirmation says and how its button is colored is in Feedback; what Raft adds for an app it hasn't reviewed is in AppLinkCard. - This is how the web app behaves, with no example here yet: slock's
packages/web/src/components/message/LinkCardActions.tsxdraws the status line (LinkCardActions), the disabled item's reason (LinkCardMenuItem) and the confirmation (LinkCardConfirmDialog). Two parts of it don't match this page yet: the confirmation is still an AlertDialog, and the status line says "In progress" while an action executes.
- Who says so?
PreviewCardFooter: the app's name and the link's host, "Stamp · stamp.build". In the iOS and Android apps the name is led by the app's 16px icon, the chip's, 4px before it: there the card covers the chip that shows the icon on desktop.
Before the reader has allowed the app, the chip stays gray with its address and has no card: a card is read-only, and its buttons can't be reached by keyboard or touch. Clicking, tapping or pressing Enter on the chip opens a Popover that asks instead, the same on every device: a question as the title, a sentence on what allowing it does, Open link to go without previews, and Show previews. It is a popover about the item (size="item", Popover): 400px, with the item card's 12px inset and title, so the question looks like the card it leads to (stdrc, 2026-11-10). A profile card is about a person, not an item, and keeps its 16px.
Behavior
- The card opens almost as soon as the pointer rests on the trigger, and closes shortly after it leaves. The delays are shorter than Base UI's, so dense messages full of mentions don't feel slow.
- It also opens when the trigger takes keyboard focus.
- It opens under the trigger, aligned to its start edge, and moves or flips at the window edge (Elevation).
- It keeps clear of the frame insets: where a shell keeps part of the window for itself (
--raft-frame-inset-top,--raft-frame-inset-start,--raft-frame-inset-end), it stops 8px from that part, not from the window's edge. The start and end insets are the corners of the top band, so they count only when its trigger is in the band; under it, it keeps its own padding from the window's edge (Page structure). The web sets none.
Content
- For an agent, say first what it is doing now, then who it is: "Reviewing #25" with its presence light, then its role and where it runs.
- For a person, show their role and their local time.
- On an item card, show the app's words as it sends them; leave out a part the app doesn't send rather than filling it with Raft's own.
- Use sentence case on the buttons: Message, View profile, Open in Stamp.
Accessibility
- PreviewCard wraps the Base UI PreviewCard. It opens on hover and on focus of the trigger, and closes on Esc.
- On desktop and phone web the card is supplementary and doesn't open on touch, and its buttons can't be reached from the keyboard: focus moves on from the trigger, and the card closes. Make the trigger a real link, to the profile or to the app's item, so everything on the card is reachable another way: a button on an item card is a shortcut to something on the page the link opens, such as View changes on a pull request. The iOS and Android apps open an app link's card on a tap instead (App links).
Rules
- Keep the card read-only: no fields, no choices. Something people fill in is a Popover.
- Put at most two small buttons on it, on one row: never pink, the confirm button in ink-border (
variant="outline") and the other frameless, as in a card in a message (Cards in messages). - Show the item's state once, in the app's own words, in a neutral Badge (
appearance="soft"): none of Raft's status colors and no status light. Which states an item has, and what they mean, is the app's concept, not Raft's; Raft's status colors and the status light mean task and presence states (Status), so mapping an app's "Merged" onto a task's "done" would put Raft's reading on the app's word. - When the app sends a color for the state, the badge takes it:
AppLinkCardBadgewithfillandsurface="popover", the same badge and the same rules as on the app's card in a message (AppLinkCard). The color is the app's own word for its state, and the card says whose it is in its footer. An app that only sends hover cards, as Stamp does for a pull request, would otherwise have no place to show the color at all: until 2026-11-14 only the card in a message took it, and no Stamp link showed one (#proj-apps:#51). - A line the app marks as a warning (
tone: "warning", such as "2 checks failing") reads inwarning-strong, as raft-ui's own warning lines do. This is Raft's color for a warning, not the app's for a state: the state's Badge takes only the app's own color, and nothing else on the card is colored. - Put no other colors of the app's on an item card: no brand color, no colored header. The app's icon, on the chip and in the apps' footer, and the fill of its state badge are the only marks of its own.
API
PreviewCard
PreviewCardArrow
Also takes the attributes of its element.
PreviewCardContent
Also takes the attributes of its element.
PreviewCardSubtitle, PreviewCardHeader, PreviewCardPopup
Takes the attributes of its element.
PreviewCardPortal
Also takes the attributes of its element.
PreviewCardSeparator, PreviewCardTitle
Takes the attributes of its element.
PreviewCardTrigger
Also takes the attributes of its element.
PreviewCardActions
Takes the attributes of its element.
PreviewCardBody
Also takes the attributes of its element.
PreviewCardEyebrow, PreviewCardFooter, PreviewCardMeta
Takes the attributes of its element.
Related
Changes
- 0.106.0 · Design SystemLong menus and popovers scroll inside the room they have ([DropdownMenu › Long menus](https://raft-design.botiverse.build/components/dropdown-menu/#long-menus), [Popover › A long popover](https://raft-design.botiverse.build/components/popover/#a-long-popover), [Elevation › Popups](https://raft-design.botiverse.build/foundations/elevation/#popups)): a popup is capped at the space left between its trigger and the window's edge, and what doesn't fit scrolls inside it, never clipped. The highlighted item of a menu stays in view and clear of the fade; the cut edges fade over up to 24px; an action on the whole list stays below the items (
DropdownMenuPinnedFooter); a popover keeps its header and buttons and scrolls its body. Changed in this release:DropdownMenuContent,ContextMenuContent,PopoverContent,PopoverBody,PreviewCardContent,PreviewCardBody. - 0.106.0 · ChangedPopoverContent, PreviewCardContent: the panel is a flex column (
flex flex-col), andPopoverHeader,PopoverSeparator,PopoverActions,PreviewCardHeader,PreviewCardSeparator,PreviewCardSubtitle,PreviewCardActionsandPreviewCardFooterdon't shrink. PopoverBody and PreviewCardBody are a ScrollArea (min-h-0, faded edges,overscroll="contain"): they scroll when the panel is capped, and are a tab stop while they overflow. - 0.103.4 · FixedFrame insets (
Popover,DropdownMenu,ContextMenu,Select,Combobox,ComboboxSelect,Tooltip,PreviewCard,CoachMark,NotificationCenter,MobileNavServerPopover,ToastPositioner,ComposerSuggestionList):--raft-frame-inset-startand--raft-frame-inset-endare the corners of the window's top band (--raft-frame-inset-top), not columns down its sides. A popup anchored under the band keeps its own padding from the window's edge; only one anchored in the band (a title-bar control, or a context menu opened in the bar) keeps 8px clear of a corner. - 0.103.3 · FixedFrame insets (
useFrameInsets,frameCollisionBoundary): opening a positioned popup (Popover,DropdownMenu,Select,Combobox,ComboboxSelect,ContextMenu,Tooltip,PreviewCard,NotificationCenter,MobileNavServerPopover,ComposerSuggestionList) no longer stalls the main thread when--raft-frame-inset-*holds acalc()orenv(titlebar-area-*)expression on an overlay title bar. - 0.103.0 · Breaking ChangesData parts named for what they hold:
SearchEntityResultDescription→SearchEntityResultSubtitle,PreviewCardDescription→PreviewCardSubtitle,TaskCardDescription→TaskCardSubtitle,MobileNavServerPopoverRowDescription→MobileNavServerPopoverRowSubtitle(and their…Propstypes), andStep'sdescriptionprop →subtitle. Their look anddata-slotvalues are unchanged. - 0.102.0 · Fixed
PopoverArrowandPreviewCardArrowpoint at their trigger on every side ([Popover › Anatomy](https://raft-design.botiverse.build/components/popover/#anatomy)). They sat at the panel's top whichever side it opened on, so they pointed the right way only for a panel below its trigger; they now sit on the edge facing the trigger, with the seam on their two outer edges, andinline-startandinline-endfollow the writing direction. - 0.102.0 · FixedOn
inline-startandinline-end,PopoverArrowandPreviewCardArrowfollow the direction Base UI placed the panel by ([Popover › Anatomy](https://raft-design.botiverse.build/components/popover/#anatomy)). They setdata-dirfrom Base UI'sDirectionProvider(ltrwithout one) and draw by it, not by the page'sdir: on adir="rtl"page with no provider, Base UI puts aninline-endpanel on the right, and the arrow drawn by the page's direction faced away from the trigger. A panel with an arrow still clips it unless the panel hasoverflow-visible. - 0.99.0 · Added
AppLinkCardBadgetakessurface="popover"for the hover card an app link opens ([AppLinkCard › The app's color](https://raft-design.botiverse.build/components/app-link-card/#the-apps-color), [PreviewCard › Item card](https://raft-design.botiverse.build/components/preview-card/#item-card)). The app's color for an item's state is now drawn on the hover card too: put<AppLinkCardBadge fill={color} surface="popover">in itsPreviewCardMeta.surfaceonly chooses the surface the hairline ring is decided against (layer-popoverin place oflayer-card, which differ in dark mode); the default,card, is the card in a message.