← All proposals

Chat Panel

A layout shell for the content of an AI chat drawer or docked side panel.

Net-new componentOpen in Storybook

proposals/ChatPanel/HANDOFF.md177 lines · View on GitHub

Handoff: ChatPanel

Rewritten 2026-11-20 against v2.0.0-beta.21 to the lessons template. Code changes the same day: props sorted alphabetically, closeButtonLabel and scrollToLatestLabel made optional with a development warning, and the file-drop handlers moved to the shared useFileDrop hook (proposals/_base/useFileDrop/).

What and why

The frame of an AI chat drawer or docked side panel: a title row with a built-in close button, a pinned header, a scrolling content area and a pinned footer. Each AI chat screen would otherwise lay out the header, context rows, conversation and composer by hand, and the chat pieces proposed here (Composer, Chat Message, Chat Attachment, Suggestion Card, Agent Avatar, Identity Block) would have nowhere to sit together. PDS has no such component. The panel owns only the layout, the scroll and the inset; every region is a slot the team fills. It is the content, not the overlay: place it inside a drawer or dock it beside the page. Figma: Chat Panel page (the designer's hand-built component set, not a capture). Context: context.md.

The proposal has two layers, so the engineer can port the first and defer the second: the frame (title row, header, content, footer, insets, dividers, close button) and three add-ons (file drop, scroll to latest, content fade). See "Frame" and "Add-ons you can defer" under API.

Exploration and decisions

  • Named Chat Panel: "Chat Drawer" would collide with the PDS Drawer and imply an overlay; PDS names its surfaces "Panel".
  • Slot props (title, header, footer, children), not compound parts: matches Composer's slots, and teams cannot reorder or repeat regions.
  • The footer slot is footer, not composer: teams also put a disclaimer or a stop bar there.
  • The view switch (Compose / Chat / Review) is a SegmentedButton the screen puts in header; the screen swaps children. The panel does not know about it.
  • headerInset, contentInset and footerInset (default or none) per region instead of negative-margin classes on the child. The title row is always inset.
  • Dividers are plain booleans, always on when set. A scroll-aware mode was not built.
  • Close button is the package CloseButton, with Drawer-style names (hasCloseButton, onClose, closeButtonLabel; no label of its own in the component, so no English in it; without a label the package CloseButton uses its own 'Close' default).
  • Default inset matches the PDS Panel content (l, then xl from the m breakpoint).
  • size is m (25rem, default) or l (37.5rem), the Drawer widths. A fill size for full-screen chat was added and removed the same day.
  • hasScrollToLatest (with scrollToLatestLabel): a floating button while scrolled away from the end, and the view follows growing content only while the person is at the end. Replaces the recipe's scrollIntoView on every update, which yanked the view down while people read earlier messages. hasContentFade is separate. The button is a bordered icon button with --pds-elevation-raised, icon anglesDown.
  • onFilesDrop + dropLabel: drag and drop over the whole panel, overlay over the content area only.
  • The working chat sample moved out to the recipe Recipes/Chat with an agent.

Full list and reasons: decisions.md.

API

ChatPanel (a div; extends div props except title). Props are in alphabetical order, as in the code (sorted 2026-11-20). Both label props are optional and log a development warning when their feature is on and the label is missing (the process.env.NODE_ENV !== 'production' pattern the package Button uses).

Frame

The part to port first.

Prop Type Default Purpose
children ReactNode none The content area. It is the only region that scrolls.
className string none Additional class names.
closeButtonLabel string none Screen-reader text and tooltip for the close button. Pass it (translated) whenever hasCloseButton is on. Optional; a development warning is logged if it is missing. Without it the package CloseButton falls back to its own 'Close' label.
contentInset 'default' | 'none' 'default' Inline padding of the content area. none bleeds to the edges.
footer ReactNode none Pinned below the content (for example the composer).
footerInset 'default' | 'none' 'default' Inline padding of the footer.
hasCloseButton boolean true Shows the built-in close button in the title row. On by default, as in the package Drawer.
hasFooterDivider boolean false Rule above the footer.
hasHeaderDivider boolean false Rule under the header.
header ReactNode none Pinned under the title row (summary strip, context rows, tabs).
headerInset 'default' | 'none' 'default' Inline padding of the header.
onClose () => void none Called when the close button is clicked.
size 'm' | 'l' 'm' Preset width, as the Drawer: 25rem or 37.5rem. It fills the height of its container.
title ReactNode none The title row, beside the close button (for example an Identity Block).

Add-ons you can defer

Each is opt-in, off by default, and independent of the frame. The engineer can port the frame now and add these later, or drop one.

Add-on Props Type Default Purpose
File drop onFilesDrop (files: File[]) => void none Setting it turns on file drop for the whole panel (title row, header, content, footer). Dragged text and links are ignored. A drop a child already handled (Composer) is not handed over again. Uses the shared useFileDrop hook.
File drop dropLabel string none Text on the drop overlay, also read to screen readers (role='status') when it appears.
Scroll to latest hasScrollToLatest boolean false Floating scroll-to-latest button while scrolled away from the end, and follow-the-end while the person is at the end.
Scroll to latest scrollToLatestLabel string none Screen-reader text and tooltip for the scroll button. Pass it with hasScrollToLatest. Optional; a development warning is logged if it is missing, and the button then has no accessible name.
Content fade hasContentFade boolean false Fades the bottom edge of the content into the footer; the last line stays clear at the end.

Exported types: ChatPanelInset, ChatPanelSize, ChatPanelProps.

Variants and states: size m / l; inset default / none per region; dividers; content fade; scroll to latest (button hidden at the end, shown when scrolled away); drag over (overlay shown). Every region is optional; the title row renders only if there is a title or hasCloseButton. Stories: Default, Bleed, Content Only, Scrolling. The drag overlay and the full chat are in the recipe Recipes/Chat with an agent.

Tokens used

  • --pds-border-width-default
  • --pds-color-border-default-secondary
  • --pds-color-foreground-default
  • --pds-color-surface-default
  • --pds-elevation-drawer-right (story frame only)
  • --pds-elevation-raised
  • --pds-spacing-2xl
  • --pds-spacing-l
  • --pds-spacing-m
  • --pds-spacing-s
  • --pds-spacing-xl

Impact

From impact.md: no existing PDS component or token is changed. One opt-in addition: a doubled selector (.pds-chat-panel__scroll-button.pds-icon-button, plus its hover state) overrides the IconButton background so content does not show through; it applies only where the net-new class is added. The report lists no proposal that imports ChatPanel, but the recipe Recipes/Chat with an agent (proposals/ChatWithAgent/) composes it, and any change to the panel's regions or scroll behaviour should be checked there.

Reused vs net-new

  • Reused: package CloseButton; the local IconButton (scroll button) and Icon (drop overlay file icon); mergeClasses from the local Button utils (_base/Button/utils); the pds-heading-l class for the drop label; the visually-hidden class. Stories compose ChatMessage and ChatMessageList and SlotPlaceholder (proposals/_story-helpers/). SlotPlaceholder is story-only: it draws the labelled boxes in the Default, Bleed, Content Only and Scrolling stories; do not port it.
  • Net-new: the hook useFileDrop (proposals/_base/useFileDrop/, shared with Composer; see Port notes); .pds-chat-panel (--m, --l, __body, __close, __content, __content--fade, __content--inset-default, __drop, __drop-icon, __drop-label, __end, __footer, __footer--divider, __footer--inset-default, __header, __header--divider, __header--inset-default, __scroll, __scroll-button, __title, __title-row); all props; custom CSS variables --chat-panel-fade-height and --chat-panel-inset. No raw values kept. Details in custom.md.

Accessibility

The same rules are in the Accessibility section of ChatPanel.mdx (the Usage page). Nothing below was run with the a11y panel, and light and dark were not checked by eye in a session: not checked.

  • No role is set on the panel; it is a plain div. Give it a role or aria-label through ...props if the screen needs a landmark (for example role='complementary').
  • Close button: the package CloseButton, a real button with a tooltip. closeButtonLabel is its label. The label is optional: when it is missing the package CloseButton uses its own 'Close' default (English, not translatable), so the button is never unlabeled, but a translated screen should pass the label. (The earlier text of this handoff said an unlabeled button results; that was wrong, corrected 2026-11-20.)
  • Scroll to latest: when on, the scroll area gets tabindex='-1' (focusable by script, not in the tab order). The button is a real IconButton with scrollToLatestLabel as label and tooltip, so it is reachable by Tab and works with Enter and Space. If the label is missing the button has no accessible name, so pass it. On activation, scrolling is instant if prefers-reduced-motion is set, and focus moves to the scroll area, since the button then disappears. The end marker is aria-hidden. Nothing is announced when the button appears.
  • Drag and drop: the overlay is aria-hidden; a visually hidden role='status' region (aria-live='polite') reads dropLabel when files are dragged over. Dropping is mouse-only; the keyboard route is the add menu in Composer, which must still exist. Composer has the same live region for its own dropLabel, so when both are on and files are dragged over the Composer, both regions announce their label; pass the same wording or leave one dropLabel out.
  • The scroll area is not itself labeled or tabbable when hasScrollToLatest is off. Keyboard users reach scrolling through focusable content inside it; check this with long non-interactive content.

Decisions and open questions

Each carries a recommended answer; these are recommendations, the designer or engineer decides.

  • Inside the PDS Drawer. The Drawer is a modal: it renders in a portal (FloatingPortal), traps focus (FocusTrap), draws a backdrop, locks body scroll, sets role='dialog' and closes on Escape. It also wraps its children in a padded, scrolling content box with its own title row and close button. ChatPanel is docked and non-modal (it sits beside the page, the page stays usable), so it cannot be a Drawer without a non-modal mode, and a modal Drawer around it would double the title row and close button. Recommendation: keep ChatPanel as its own docked component, and do not add a non-modal Drawer mode for this. If a team wants it as an overlay, they place it inside a Drawer only with a "no wrapper" option on the Drawer (not proposed here). Verified against .pds-reference/src/components/overlays/Drawer/Drawer.tsx at beta.21.
  • Port the frame first, add-ons later. Recommendation: port the frame, then decide on file drop, scroll to latest and the fade one by one (each is opt-in and off by default). The drop handlers are the shared hook; if the engineer drops the drop add-on, Composer still needs its own.
  • Does the empty state ("Work it out in conversation", in the recipe) need its own component? Recommendation: no, keep it a recipe composition; its XL heading would need a size option on VerticalEmptyState or a local variant if it is ever promoted.
  • Dragging a file out of the window can leave the drop overlay up until the next dragenter or drop. Recommendation: add a window-level dragend reset only if it shows up in testing.
  • Widths, breakpoints and small screens need the designer's specs. There is no container query; the inset breakpoint is the viewport's (as in the Panel), not the panel's width. Recommendation: keep the viewport breakpoint until a spec says otherwise.
  • Should the scroll button stay a square icon button, or become a circle (one border-radius away)? A "new messages" dot or label was left out. Recommendation: keep the square button.
  • Because ...props come last, a consumer's own onDrop or onDrag* replaces the panel's handlers. Recommendation: accept it and say so in the docs, as the hook is spread before ...props.
  • The sample header's neutral grey Tag trial (a PDS Tag has no neutral color) belongs to the recipe, not this component.

Extension or new component

New component, not an extension. No PDS component is the frame of a docked chat: the package Drawer is the closest, and it cannot be extended into this without a non-modal mode (see the Drawer question above), and the package Panel is a minimally styled container for grouping content, not a column with a pinned header and footer and one scrolling region (not verified in detail). It reuses the package CloseButton and the Drawer widths (size), and its close button props mirror the Drawer's names.

Footprint

What draws outside the box, and what a parent could clip or size wrongly:

  • The panel root is height: 100%, overflow: hidden and width from size (with max-width: 100%). The parent must give it a height; with none the panel collapses. overflow: hidden on the root clips anything a child draws outside it (a Composer MenuButton or Select popup in the footer that is not portaled; the Composer focus ring at the footer edge). Test the footer at the panel edge.
  • position: absolute parts, both inside __body (position: relative), over the content area: the scroll-to-latest button (__scroll, bottom center, z-index: 1, the wrapper ignores the pointer so only the button takes clicks) and the drop overlay (__drop, inset: 0, z-index: 1, pointer-events: none). A parent that sets its own stacking order should not put something between them and the content.
  • hasContentFade puts a mask-image (with the -webkit- prefix) on the scrolling element, so anything a child draws outside that element is masked at the element edge: focus rings and tooltips of children near the bottom edge, and any overflow-visible popup. The scroll button is outside the masked element, so the fade does not hide it.
  • The fade adds padding-block-end equal to its height (--pds-spacing-2xl) so the last line stays clear.
  • Not checked by eye: how these look next to Composer, Chat Message and the Identity Block in light and dark.

Dark mode and per-size values

The CSS has no per-theme override: every color is a semantic token that the package switches by theme. Only values that exist in chat-panel.css:

Part Value Per size / breakpoint Per theme
Width 25rem (m), 37.5rem (l), max-width: 100% per size none
Inline inset --pds-spacing-l; --pds-spacing-xl from 768px (--chat-panel-inset) per viewport (min-width: 768px), not per size none
Fade height --pds-spacing-2xl (--chat-panel-fade-height) single size none (a mask, no color)
Dividers --pds-border-width-default, --pds-color-border-default-secondary single size no per-theme override (token)
Scroll button --pds-color-surface-default fill, --pds-elevation-raised, size='s' single size no per-theme override (tokens)
Drop overlay sheet --pds-color-surface-default at opacity: 0.92 single size no per-theme override; opacity is a raw number
Drop icon and label Icon file at 4xl, label pds-heading-l single size no per-theme override

Dark mode: not checked by eye in a session.

Expect to change

Choices that break a toolkit convention, each with a recommended answer (L2, L3, L10):

  • Bundled add-ons (L2, L7). File drop, scroll to latest and the fade ride along with the frame. Recommendation: port the frame first and treat the three as separable (see "Add-ons you can defer").
  • Optional labels. closeButtonLabel and scrollToLatestLabel are optional, with a development warning (the package Button pattern). Recommendation: keep. The scroll button uses the proposal's IconButton, whose ariaLabel is a required string (the package IconButton is the same), so the code passes scrollToLatestLabel as string; in the port, either keep the label required on the panel when hasScrollToLatest is on or do not render the button without a label.
  • Screen-reader text as top-level props (L3). The labels are top-level, translatable props, not fields of another prop's object. Recommendation: keep. Note that dropLabel is both the visible overlay text and the announcement (one string), and Composer announces its own dropLabel too (see Accessibility).
  • Insets as a union. headerInset, contentInset, footerInset take 'default' | 'none', the same union three times. Recommendation: keep as is; if the toolkit prefers flat booleans, hasHeaderInset and so on are a rename with no CSS change.
  • size mirrors the Drawer widths (m, l). Recommendation: keep; reuse the Drawer's size type if the port can share it.
  • hasCloseButton defaults on. Matches the Drawer. Recommendation: keep.
  • Shared file-drop hook. Drop logic is in useFileDrop, shared with Composer. Recommendation: port it to src/utilities/hooks/ (as useFileDrop) or inline it; do not keep two copies.

Target-version check

Checked against .pds-reference/ at v2.0.0-beta.21 (CHANGELOG.mdx and src):

  • CloseButton (package): exists; ariaLabel is optional with default 'Close'.
  • Icons anglesDown and file: both exist in generated-icon-data.ts; neither is new.
  • Drawer widths m 25rem and l 37.5rem: exist (drawer.css).
  • pds-heading-l and visually-hidden: exist in the package CSS.
  • No ChatPanel or file-drop hook exists in the package; src/utilities/hooks/ has useBreakpoint, useClipboard, useDropdown, useIsMobile, useKeyPress, useKeyboardShortcut, useMediaQuery, useWindowWidth. Nothing here was already shipped.
  • Package Button development-warning pattern (process.env.NODE_ENV !== 'production' with console.warn): exists.

Port notes

Would live in src/components/ (a chat or conversation category folder; generator npm run generate:component). Not yet matching v2: the local mergeClasses stand-in (use @libs/components/utils); the local Icon and IconButton wrappers (use the ported ones); the inset breakpoint is written @media (min-width: 768px) because the custom media form does not work in this repo, so restore @media (--pds-bp-m); the scroll button override relies on a doubled selector against the IconButton background; the fade uses mask-image with the -webkit- prefix. A drawer holding a size='m' panel should use the same size. The hook useFileDrop lives in proposals/_base/useFileDrop/useFileDrop.ts (real component code, not a proposal; it has no handoff of its own). The toolkit has src/utilities/hooks/, which is where it would go.

Dependencies (from node scripts/port-order.mjs --needs=ChatPanel): Button, Icon, IconButton, Spinner, ChatMessage (composed in the stories) and AgentAvatar. All are marked ready for dev except AgentAvatar, which has already shipped in PDS beta.18 (used from the package), so none is blocking. Port IconButton and Icon before this one.

Preview

npm run storybook, story Component Proposals / AI Chat / Chat Panel (change size in the controls). The full chat is Recipes / Chat with an agent. Figma: https://www.figma.com/design/AMGWJbraJoi2PKWnxo29Ah/PDS-Proposals?node-id=255-468