Skip to content
SettingsShare dialogMenu

Share dialog

Share a chat as a snapshot: who can open it, the link with Copy link, a note that later messages stay private, Update link, and export as Markdown or PDF.

Pick who can open it, create and copy the link, export as Markdown or PDF.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/share-dialog.json

Usage

tsx
import { ShareDialog } from "@/components/ui/chatcn/share-dialog"

<ShareDialog
  trigger={<Button size="sm" variant="outline"><ShareIcon />Share</Button>}
  chatTitle={chat.title}
  messages={chat.messages.slice(0, 4)}
  messageCount={chat.messages.length}
  workspace="Tidewater"
  link={share?.url}
  onCreateLink={async (visibility) => (await createShare(chat.id, visibility)).url}
  onDeleteLink={() => deleteShare(chat.id)}
  onExport={(format) => exportChat(chat.id, format)}
/>

Examples

A chat that has moved on since its link was made. Open Share to update the link.

Props

PropTypeNotes
open, defaultOpen, onOpenChange, triggerDialog state
chatTitle, messages, messageCountThe snapshot. Or pass preview
visibility, defaultVisibility, onVisibilityChange"private" | "workspace" | "link"
workspacestringAdds People in {workspace}
linkstringThe current link
onCreateLink(visibility) => string | Promise<string>Throw to show the error
newMessagesnumberShows Update link
onDeleteLink() => void
onExport(format: "markdown" | "pdf") => void | Promise<void>Progress on the button

Keyboard

KeyAction
Arrow keys in Who can open itMove and select
EscClose the dialog

Accessibility

  • Built on the chatcn dialog: focus is trapped and returns to the Share button. The snapshot is decorative and hidden from screen readers; its caption says what is shared.
  • Copy link announces Copied. Export buttons announce when the file is ready or the export failed.

Motion

  • The dialog grows from 0.96 over 220 ms, and opens instantly from the keyboard.
  • Copy link and export icons swap with the 150 ms blur crossfade; the buttons never change size.