Handoff: Composer
Rewritten 2026-11-20 against v2.0.0-beta.21 to the lessons template. Code changes the same day: props sorted alphabetically (disabled before dropLabel, value before variant), the copy-pasted drop handlers replaced by the shared useFileDrop hook (proposals/_base/useFileDrop/), a role='status' live region that announces dropLabel, and the drop label's font size taken from the pds-copy-s class instead of a size token in the CSS.
What and why
The field for composing a prompt on chat and agent screens. PDS has Textarea, but its border sits on the <textarea> itself, so there is nowhere to put a toolbar (add menu, model selector, voice, Send) inside the box. Composer moves the border, background, focus ring and resize handle to a wrapper (the "field") that holds the textarea and the toolbar. It is the largest of the chat components: four slots (aboveField, fieldHeader, actionsStart, actionsEnd), two variants (default, compact) and opt-in file drag and drop. It holds no buttons or text of its own; the screen fills the slots. Figma: Composer page (the designer's hand-built components, not a capture). Context: context.md.
Exploration and decisions
- A new component, not a
Textareaprop: the wrapper has to own the border so the toolbar sits inside it. Label, helper message, focus ring,sizeandisResizablemirrorTextarea, and the markup reuses the package'spds-input,pds-input-labelandpds-input-messageclasses (InputLabelandInputMessageare internal to the toolkit, ininputs/input-utilities.tsx, and not exported from the package). - Slots, not built-in buttons. The story composes
IconButton,MenuButton(add menu), the bareSelect(model) and a primaryIconButton(Send). The model selector was a separateModelSelectorproposal; it was replaced bySelectwithvariant='bare'on 2026-10-19. aboveField(a grey context bar on the top edge, outside the border) andfieldHeader(attachments, inside the border) are named by position. Both work in both variants. Attachments go infieldHeader; the idea of putting them inaboveFieldwas dropped (2026-10-21).compactis a single-line bar with the controls on the same row, standard input radius (not a pill), not resizable. The DOM follows the visual order so keyboard order matches. It keeps the rounded-square Send button, not the reference's circle.- Label hidden by default (
showLabelisfalse), still required and rendered for screen readers. - Drag and drop is opt-in through
onFilesDrop; the component only reports the droppedFile[], through the shareduseFileDrophook. Only file drags are intercepted, so dragging text into the textarea still works. The drag-over look is a dashed focus border on the info-blue fill. - Left out of the first version (present in
Textarea): see "Textarea features left out" below. - No separate attach button in the samples; the add menu has "Add photos & files".
Full list and reasons: decisions.md.
API
Composer (a div; extends div props except defaultValue, onChange and placeholder; the ref goes to the <textarea>):
| Prop | Type | Default | Purpose |
|---|---|---|---|
aboveField |
ReactNode |
none | Bar on the top edge, outside the border (for example the branch the prompt applies to). |
actionsEnd |
ReactNode |
none | Toolbar controls at the end, inside the field (model selector, voice, Send as a primary IconButton). |
actionsStart |
ReactNode |
none | Toolbar controls at the start, inside the field (add menu). |
className |
string |
none | Additional class names. |
defaultValue |
string |
none | Initial value (uncontrolled); not with value. |
disabled |
boolean |
false |
Disables the textarea and turns off drop. |
dropLabel |
string |
none | Text over the field while files are dragged onto it, also read to screen readers (role='status'); without it only the border and fill change. |
fieldHeader |
ReactNode |
none | Inside the border above the text (attached files). In compact it sits above the row. |
id |
string |
none (req.) | ID of the textarea; also the name, and the base of the label and message ids. |
isResizable |
boolean |
true |
Drag the bottom corner to resize. Ignored in compact. |
label |
string |
none (req.) | Label of the field. |
message |
ReactNode |
none | Helper message below the field; linked with aria-describedby. |
onChange |
(event: ChangeEvent<HTMLTextAreaElement>) => void |
none | Change handler (controlled use). |
onFilesDrop |
(files: File[]) => void |
none | Turns on file drop; receives the dropped files. |
placeholder |
string |
none | Text shown when empty. |
rows |
number |
3 |
Visible rows above the toolbar (always 1 in compact). |
showLabel |
boolean |
false |
Show the label; otherwise it is visually hidden. |
size |
's' | 'm' |
's' |
Padding (--composer-padding). |
textareaProps |
ComponentPropsWithoutRef<'textarea'> |
none | Extra props for the <textarea>; spread last, so they override. |
value |
string |
none | Value (controlled); not with defaultValue. |
variant |
'default' | 'compact' |
'default' |
default: tall field, toolbar underneath. compact: one row. Kept a variant (not a flat boolean) because it changes the DOM order. |
Variants and states: default and compact; sizes s and m; disabled; resizable or not; drag-over (pds-is-drag-over, with and without dropLabel); each slot filled; failed attachments with a helper message. Stories: Default, Compact, With Above Field, With Field Header, With Attachment Errors, With All Properties, Slots (Usage page only).
Tokens used
In composer.css (the component):
--pds-border-radius-input--pds-border-width-default--pds-border-width-outline--pds-color-border-default-secondary--pds-color-border-input--pds-color-foreground-default--pds-color-input-placeholder--pds-color-interactive-focus--pds-color-status-info-background--pds-color-status-info-foreground--pds-color-surface-default--pds-color-surface-default-secondary--pds-spacing-2xs--pds-spacing-s--pds-spacing-xs--pds-typography-ff-default--pds-typography-lh-l--pds-typography-size-s
In composer-story.css only (story scaffolding, not the component): --pds-color-foreground-default, --pds-color-foreground-default-secondary, --pds-color-status-critical-foreground, --pds-spacing-2xl, --pds-spacing-2xs, --pds-spacing-4xs, --pds-spacing-xs, --pds-typography-size-xs.
The drop label no longer sets its own font size: its text has the package class pds-copy-s (2026-11-20), so --pds-typography-size-s is used in the component only by the textarea. npm run check:tokens: 0 problems repo-wide on 2026-11-20 (4 inline-style warnings in other proposals).
Impact
From impact.md: no existing PDS component is changed and no --pds-* token is redefined; everything is scoped to .pds-composer*. The only shared class is .pds-is-resizable, used as .pds-composer__field.pds-is-resizable, so existing uses are unaffected. No other proposal imports it by code (the Chat with an agent recipe uses it in its story; port Composer before it).
Reused vs net-new
- Reused: the package classes
pds-input,pds-input-label,pds-input-message,pds-is-disabled,pds-is-resizable,pds-copy-s(drop label text),visually-hidden. Composed in stories (slots): localIconButton,MenuButton,Select(bare variant),ChatAttachment, andIcon. TheSlotsstory is used by the Usage page and hidden from the sidebar; the greycomposer-story.cssblocks in the stories are story-only scaffolding. - Net-new:
.pds-composerwith--compact,--m,__above-field,__actions,__actions-end,__actions-start,__drop-label,__field,__field-header,__row,__textarea; the state classpds-is-drag-over; all props; one custom variable,--composer-padding; the hookuseFileDrop(proposals/_base/useFileDrop/, shared with Chat Panel). No raw values kept. Details incustom.md.
Accessibility
The same rules are in the Accessibility section of Composer.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.
- A real
<label>tied to the textarea byhtmlFor; hidden visually by default withvisually-hidden, still read by screen readers.messageis linked witharia-describedby. - The textarea is native, so keyboard and typing behave as usual. Focus: the ring is
:focus-withinon the field (--pds-border-width-outline,--pds-color-interactive-focus), so it also shows when a toolbar control has focus. Toolbar controls keep their own focus styles and keyboard behavior (IconButton, MenuButton, Select). - Compact: the DOM order is start controls, text, end controls, matching the visual order.
- Drag and drop is a pointer shortcut. The
dropLabeloverlay isaria-hidden; since 2026-11-20 a visually hiddenrole='status'region (aria-live='polite') inside the field readsdropLabelwhen files are dragged over (the same rule as Chat Panel; it exists only whileonFilesDropis set and the field is not disabled). When Composer sits in a Chat Panel that also has adropLabel, both regions announce their label while files are over the Composer; use the same wording or leave one out. Keyboard users add files through the add menu (the screen must provide that path). - Failed attachments: the screen writes one
role='alert'helper message (shown in the story).
Decisions and open questions
Each carries a recommended answer; these are recommendations, the designer or engineer decides.
- Enter and Shift+Enter are left to the screen (the story's helper text only says "Enter to send"). Should send-on-Enter be built in, with an IME-composition guard? Recommendation: no; keep it on the screen, which knows when Send is allowed.
- Agentic border: should the field get the AI gradient border (for example while the agent works), like Button? Not added. Recommendation: leave it until an agentic input exists in the package.
- Compact growth: one row now; should it grow to a maximum height as a long prompt is typed? The reference's voice-mode waveform when empty is not included. Recommendation: yes later, as a separate change.
- Character counter or maximum length: not built. Recommendation: do not add until chat needs a limit;
TextareahascounterMaxLengthif it does. - Menu features
MenuButtondoes not support but the references show (trailing status or shortcut hints, selected toggles, submenus, count badges). Recommendation: raise againstMenuButton, not Composer; toggles for tools are the likely first need. - The model selector shows a chevron (the Select's trigger icon); the design shows text only. Recommendation: confirm with the designer.
- Drag-over: which
dropLabelwording, and should the overlay hide the textarea as in the references? Recommendation: keep the current overlay, wording is the screen's. - Attachments: should
fieldHeaderget a max height with scroll when many files are attached? Should the bar show incompact? AnerrorTypeto drive retry versus remove-only is also open. Recommendation: add a max height with scroll when a screen needs it. textareaPropsis spread after the built-in props, so it can overrideid,rowsoronChange. Recommendation: keep it last (the same asTextarea) and document that it overrides.- The voice icon
microphoneLinesis staged in the Icon proposal; the port adds it to the icon registry (see Target-version check). - Hook scope: the drop logic is
useFileDrop, shared with Chat Panel. Recommendation: port it tosrc/utilities/hooks/or inline it; do not keep two copies.
Extension or new component
New component, not an extension of Textarea (a recommendation, the designer decided to keep it new). Textarea puts the border, background and focus ring on the <textarea> itself, so there is nowhere to put a toolbar inside the box. Composer moves them to a wrapper (the field) that holds the textarea and the toolbar slots. An extension would mean a wrapper element inside Textarea for every use, plus aboveField, fieldHeader and the toolbar slots, which the plain field does not need. Human behavior of Textarea is untouched: nothing in the package is edited.
Textarea features left out, and why:
Textarea feature |
Left out because |
|---|---|
required, required marker |
A prompt is not a form field with a required state. |
tooltipText (label tooltip) |
The label is hidden by default and the placeholder says what the field is for. |
counterMaxLength, character counter |
No limit is set in chat; open question above. |
readonly |
A prompt field is either editable or disabled. |
inputWidth, inputWidthMin |
The field fills its container (the Chat Panel footer). |
validationStatus, validationMessage |
Nothing to validate; send failures belong in the conversation. message still takes a helper message. |
translationStrings |
No built-in text; the label, placeholder and drop label are props. |
onBlur, onFocus as named props |
Reachable through textareaProps. |
Convention-breaking choices and a recommendation for each (L10):
- A new component instead of
Textarea. Recommendation: keep the new component (above). pds-input*classes instead ofInputLabelandInputMessage. The markup copies the label and message markup because the proposal cannot import them. Recommendation: in the port, useInputLabelandInputMessagefrominputs/input-utilities.tsx; they are internal to the toolkit (not exported from the package, checked inindex.source.ts), so the port can import them by relative path and the copy goes away.textareaPropslast. Recommendation: keep it last; it is the same escape hatchTextareahas.variant='compact'is a variant, not a flat boolean. It changes the DOM order, not only the look. Recommendation: keep the variant, as the TSDoc says.sizeandvariantboth change density.sizeis padding (s,m),variantis layout. Recommendation: keep both; do not merge.- Local
mergeClassesstand-in. Recommendation: use the toolkit's.
Footprint
What draws outside the box, and what a parent could clip or size wrongly:
.pds-composer__fieldhasoverflow: hidden(andposition: relative) so the rounded border clips the content and the resize handle sits in the corner. Anything a toolbar control draws outside the field is clipped unless it is portaled: aMenuButtonorSelectpopup inactionsStartoractionsEnd, a tooltip. Checked 2026-11-20 in Storybook (DOM, not by eye): theMenuButtonmenu and the bareSelectlistbox open without error in both the default and thecompactvariant, and each renders outside the field element, so neither is clipped byoverflow: hidden. A custom popup that does not portal will clip. A chip infieldHeaderwhose remove button sits outside its tile (Chat Attachment) can be cut at the field edge.position: absoluteparts inside the field: the drop label overlay (inset: 0,z-index: 1,pointer-events: none) and the visually hidden live region..pds-composer__above-fieldis outside the field border (a grey bar on the top edge with a--pds-spacing-xsinline margin and no bottom border), so the component is taller than the field alone.- Resizing:
resize: verticalis on the field, not the textarea. A parent with a fixed height will clip a field the person resizes taller; in the Chat Panel footer the footer grows and the content area shrinks. - The focus ring is an
outlineon the field (offset0), so a clipping parent cuts it at the Composer edge (see the Chat Panel footprint).
Dark mode and per-size values
The CSS has no per-theme override: colors are semantic tokens that the package switches by theme. The drag-over colors (--pds-color-status-info-background, --pds-color-status-info-foreground, --pds-color-interactive-focus, --pds-color-border-input) are tokens, and each has a dark value in the package's variables.dark.css (read, not seen). Dark mode: not checked by eye in a session.
| Part | Value | Per size / variant | Per theme |
|---|---|---|---|
Padding (--composer-padding) |
--pds-spacing-xs (s), --pds-spacing-s (m) |
per size; the compact row uses --pds-spacing-xs for both sizes |
none |
| Toolbar padding | --pds-spacing-2xs --pds-spacing-xs --pds-spacing-xs |
single size | none |
| Border, radius | --pds-border-width-default, --pds-color-border-input, --pds-border-radius-input |
single size (compact keeps the input radius) | no per-theme override (tokens) |
| Focus ring | --pds-border-width-outline outline, --pds-color-interactive-focus |
single size | no per-theme override (token) |
| Drag-over field | dashed --pds-color-interactive-focus border, --pds-color-status-info-background fill |
single size | no per-theme override (tokens) |
| Drop label | --pds-color-status-info-foreground on --pds-color-status-info-background, pds-copy-s |
single size | no per-theme override (tokens) |
| Textarea type | --pds-typography-ff-default, --pds-typography-size-s, --pds-typography-lh-l |
single size | none |
Expect to change
Choices that break a toolkit convention, each with a recommended answer (L2, L10):
- New component, not a
Textareaextension. Recommendation: keep (see above). - Copied
pds-input*markup. Recommendation: replace withInputLabelandInputMessagein the port. labelandidare required, as onTextarea. Recommendation: keep.textareaPropsspread last. Recommendation: keep.variant='compact'. Recommendation: keep the variant because of the DOM order.- Drop label announced by Composer and by Chat Panel. Both regions announce. Recommendation: keep one
dropLabelper surface, or accept the double announcement. - Local
mergeClassesand the local hook folder. Recommendation: use the toolkit'smergeClasses; portuseFileDroptosrc/utilities/hooks/. - Drop label type. Uses the
pds-copy-sclass. The textarea still sets family, size and line height from tokens because nopds-copy-*class has thelh-lline height. Recommendation: keep.
Target-version check
Checked against .pds-reference/ at v2.0.0-beta.21 (CHANGELOG.mdx and src):
Textarea: exists with the props listed above; Composer is not in the package.InputLabel,InputMessage: exist insrc/components/inputs/input-utilities.tsx; not exported fromsrc/index.source.ts.pds-input,pds-input-label,pds-input-message,pds-is-resizable,pds-is-disabled,visually-hidden,pds-copy-s: used by package components or defined in the package CSS (pds-copy-sintypography-styles.css,visually-hiddenina11y.css). The others were not individually grepped: not verified.- Tokens used: all
--pds-*names are in the package's design-token CSS (check:tokenspasses). The drag-over colors have dark values. - Icon
microphoneLines(used by the story's voice button, staged in the Icon proposal): not verified here; see the Icon handoff. - No file-drop hook exists in the package;
src/utilities/hooks/hasuseBreakpoint,useClipboard,useDropdown,useIsMobile,useKeyPress,useKeyboardShortcut,useMediaQuery,useWindowWidth.
Port notes
Would live in src/components/ in an inputs or chat category folder (generator npm run generate:component). Not yet matching v2: the local mergeClasses stand-in (use @libs/components/utils), and the markup reuses pds-input* classes instead of InputLabel and InputMessage (use those from inputs/input-utilities.tsx). The textarea declares font family, size and line height from tokens (no pds-copy-* class matches the line height); the drop label uses pds-copy-s. The file-drop hook is proposals/_base/useFileDrop/useFileDrop.ts (real code, shared with Chat Panel, no handoff of its own); the toolkit has src/utilities/hooks/, where it would go. The story composes local proposals, so the port needs them first.
Dependencies on other proposals:
- Select (
Component Proposals/Select, bare variant): ready for dev; Composer composes it, so port Select first. - ChatAttachment (
AI Chat/Chat Attachment): ready for dev; used in stories only (thefieldHeadersamples), so it does not block the component. - Marked ready: IconButton (its
primaryvariant andisWorkingare the Send button; they use Spinner and thestopicon in the Icon wrapper), MenuButton, Icon and Button. - Port order: see
docs/PORT-ORDER.md(node scripts/port-order.mjs --needs=Composerprints the graph); Composer goes after Select.
Preview
npm run storybook, story Component Proposals / AI Chat / Composer. Figma: https://www.figma.com/design/AMGWJbraJoi2PKWnxo29Ah/PDS-Proposals?node-id=213-43