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
Drawerand 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, notcomposer: teams also put a disclaimer or a stop bar there. - The view switch (Compose / Chat / Review) is a
SegmentedButtonthe screen puts inheader; the screen swapschildren. The panel does not know about it. headerInset,contentInsetandfooterInset(defaultornone) 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 packageCloseButtonuses its own'Close'default). - Default inset matches the PDS Panel content (
l, thenxlfrom thembreakpoint). sizeism(25rem, default) orl(37.5rem), the Drawer widths. Afillsize for full-screen chat was added and removed the same day.hasScrollToLatest(withscrollToLatestLabel): 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'sscrollIntoViewon every update, which yanked the view down while people read earlier messages.hasContentFadeis separate. The button is a bordered icon button with--pds-elevation-raised, iconanglesDown.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 localIconButton(scroll button) andIcon(drop overlayfileicon);mergeClassesfrom the local Button utils (_base/Button/utils); thepds-heading-lclass for the drop label; thevisually-hiddenclass. Stories composeChatMessageandChatMessageListandSlotPlaceholder(proposals/_story-helpers/).SlotPlaceholderis 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-heightand--chat-panel-inset. No raw values kept. Details incustom.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 aroleoraria-labelthrough...propsif the screen needs a landmark (for examplerole='complementary'). - Close button: the package
CloseButton, a real button with a tooltip.closeButtonLabelis its label. The label is optional: when it is missing the packageCloseButtonuses 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 realIconButtonwithscrollToLatestLabelas 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 ifprefers-reduced-motionis set, and focus moves to the scroll area, since the button then disappears. The end marker isaria-hidden. Nothing is announced when the button appears. - Drag and drop: the overlay is
aria-hidden; a visually hiddenrole='status'region (aria-live='polite') readsdropLabelwhen 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 owndropLabel, so when both are on and files are dragged over the Composer, both regions announce their label; pass the same wording or leave onedropLabelout. - The scroll area is not itself labeled or tabbable when
hasScrollToLatestis 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, setsrole='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.tsxat 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
VerticalEmptyStateor 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
dragendreset 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-radiusaway)? A "new messages" dot or label was left out. Recommendation: keep the square button. - Because
...propscome last, a consumer's ownonDroporonDrag*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: hiddenandwidthfromsize(withmax-width: 100%). The parent must give it a height; with none the panel collapses.overflow: hiddenon the root clips anything a child draws outside it (a ComposerMenuButtonorSelectpopup in the footer that is not portaled; the Composer focus ring at the footer edge). Test the footer at the panel edge. position: absoluteparts, 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.hasContentFadeputs amask-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-endequal 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.
closeButtonLabelandscrollToLatestLabelare optional, with a development warning (the packageButtonpattern). Recommendation: keep. The scroll button uses the proposal'sIconButton, whoseariaLabelis a requiredstring(the packageIconButtonis the same), so the code passesscrollToLatestLabel as string; in the port, either keep the label required on the panel whenhasScrollToLatestis 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
dropLabelis both the visible overlay text and the announcement (one string), and Composer announces its owndropLabeltoo (see Accessibility). - Insets as a union.
headerInset,contentInset,footerInsettake'default' | 'none', the same union three times. Recommendation: keep as is; if the toolkit prefers flat booleans,hasHeaderInsetand so on are a rename with no CSS change. sizemirrors the Drawer widths (m,l). Recommendation: keep; reuse the Drawer's size type if the port can share it.hasCloseButtondefaults on. Matches the Drawer. Recommendation: keep.- Shared file-drop hook. Drop logic is in
useFileDrop, shared with Composer. Recommendation: port it tosrc/utilities/hooks/(asuseFileDrop) 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;ariaLabelis optional with default'Close'.- Icons
anglesDownandfile: both exist ingenerated-icon-data.ts; neither is new. Drawerwidthsm25rem andl37.5rem: exist (drawer.css).pds-heading-landvisually-hidden: exist in the package CSS.- No
ChatPanelor file-drop hook exists in the package;src/utilities/hooks/hasuseBreakpoint,useClipboard,useDropdown,useIsMobile,useKeyPress,useKeyboardShortcut,useMediaQuery,useWindowWidth. Nothing here was already shipped. - Package
Buttondevelopment-warning pattern (process.env.NODE_ENV !== 'production'withconsole.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