Skip to content
Sign upPro
FramesSite widgetMenu

Site widget

A website with a support assistant in the corner: launcher, nudge, a panel that grows out of the launcher into a chat with sources, and a handoff to a person. A full screen sheet on phone viewports.

The nudge, the panel growing from the launcher, a question, Thinking, and the answer with its source. Loops; use the widget to take over.

Installation

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

Usage

tsx
import {
  SiteWidgetFrame,
  WidgetMessage,
  WidgetSources,
} from "@/components/ui/chatcn/site-widget"

<SiteWidgetFrame
  assistant={{ name: "Wren", initials: "W" }}
  nudge="Questions about plans? Ask me."
  chips={["Change plan", "Talk to a person"]}
  composer="live"
  onSend={(text) => chat.send(text)}
>
  <WidgetMessage from="user">Can I change plans mid month?</WidgetMessage>
  <WidgetMessage from="assistant" pending={chat.status === "submitted"}>
    {answer}
    <WidgetSources sources={[{ title: "Billing FAQ", href: "/help/billing" }]} />
  </WidgetMessage>
</SiteWidgetFrame>

The site lays out at a true 1280 by 800 viewport and scales to fit. Pass your own page as site; the default is a quiet drawn page so the widget stays the subject. Under a 640 px viewport (not page) width the panel becomes a full screen sheet with a top bar, as it would on a phone.

The panel is a dialog named by the assistant. Opening it from the launcher or the nudge moves focus in; Escape or the close button closes it and gives focus back to the launcher. A scripted open never takes focus from the page. On the sheet, Tab stays inside.

A pending reply shows nothing for 300 ms, then Thinking, held at least 400 ms, in the place the answer lands. composer is static by default (drawn, not focusable), live to send with Enter (never during IME composition), or none.

Examples

States

Closed, the nudge, open with sources and chips, a handoff to a person, the phone sheet inside PlainScreen, and a dark site on a light page.

Closed, the nudge, open with sources and chips, a handoff to a person, the phone sheet and a dark site.

Props

PropTypeNotes
assistant{ name, initials }Names the panel and its avatar
siteReactNodeThe host page. Default SitePlaceholder
chrome, addressbrowser | none, stringThe browser bar and its address
open, defaultOpen, onOpenChangebooleanControlled or not
nudge, nudgeAfterstring, numberShown after 800 ms, gone once opened or dismissed
chips, onChipstring[]One row that scrolls sideways
composer, onSendstatic | live | noneDefault static
placeholderstringDefault “Ask a question…”
welcome, intro, stampboolean, string, string | falseThe greeting, one line under it, and the Today stamp
viewport, width, bezel, radiusFrame propsDefault 1280 by 800, hairline, 12

Parts: WidgetMessage (from is user, assistant or person, with author and pending), WidgetSources, WidgetChips and WidgetHandoff (a centred rule with the teammate's initials).