← All proposals

Composer

A labelled textarea with a toolbar inside the same bordered box:

Net-new componentOpen in Storybook

proposals/Composer/HANDOFF.md202 lines · View on GitHub

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 Textarea prop: the wrapper has to own the border so the toolbar sits inside it. Label, helper message, focus ring, size and isResizable mirror Textarea, and the markup reuses the package's pds-input, pds-input-label and pds-input-message classes (InputLabel and InputMessage are internal to the toolkit, in inputs/input-utilities.tsx, and not exported from the package).
  • Slots, not built-in buttons. The story composes IconButton, MenuButton (add menu), the bare Select (model) and a primary IconButton (Send). The model selector was a separate ModelSelector proposal; it was replaced by Select with variant='bare' on 2026-10-19.
  • aboveField (a grey context bar on the top edge, outside the border) and fieldHeader (attachments, inside the border) are named by position. Both work in both variants. Attachments go in fieldHeader; the idea of putting them in aboveField was dropped (2026-10-21).
  • compact is 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 (showLabel is false), still required and rendered for screen readers.
  • Drag and drop is opt-in through onFilesDrop; the component only reports the dropped File[], through the shared useFileDrop hook. 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): local IconButton, MenuButton, Select (bare variant), ChatAttachment, and Icon. The Slots story is used by the Usage page and hidden from the sidebar; the grey composer-story.css blocks in the stories are story-only scaffolding.
  • Net-new: .pds-composer with --compact, --m, __above-field, __actions, __actions-end, __actions-start, __drop-label, __field, __field-header, __row, __textarea; the state class pds-is-drag-over; all props; one custom variable, --composer-padding; the hook useFileDrop (proposals/_base/useFileDrop/, shared with Chat Panel). No raw values kept. Details in custom.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 by htmlFor; hidden visually by default with visually-hidden, still read by screen readers. message is linked with aria-describedby.
  • The textarea is native, so keyboard and typing behave as usual. Focus: the ring is :focus-within on 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 dropLabel overlay is aria-hidden; since 2026-11-20 a visually hidden role='status' region (aria-live='polite') inside the field reads dropLabel when files are dragged over (the same rule as Chat Panel; it exists only while onFilesDrop is set and the field is not disabled). When Composer sits in a Chat Panel that also has a dropLabel, 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; Textarea has counterMaxLength if it does.
  • Menu features MenuButton does not support but the references show (trailing status or shortcut hints, selected toggles, submenus, count badges). Recommendation: raise against MenuButton, 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 dropLabel wording, and should the overlay hide the textarea as in the references? Recommendation: keep the current overlay, wording is the screen's.
  • Attachments: should fieldHeader get a max height with scroll when many files are attached? Should the bar show in compact? An errorType to drive retry versus remove-only is also open. Recommendation: add a max height with scroll when a screen needs it.
  • textareaProps is spread after the built-in props, so it can override id, rows or onChange. Recommendation: keep it last (the same as Textarea) and document that it overrides.
  • The voice icon microphoneLines is 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 to src/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 of InputLabel and InputMessage. The markup copies the label and message markup because the proposal cannot import them. Recommendation: in the port, use InputLabel and InputMessage from inputs/input-utilities.tsx; they are internal to the toolkit (not exported from the package, checked in index.source.ts), so the port can import them by relative path and the copy goes away.
  • textareaProps last. Recommendation: keep it last; it is the same escape hatch Textarea has.
  • 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.
  • size and variant both change density. size is padding (s, m), variant is layout. Recommendation: keep both; do not merge.
  • Local mergeClasses stand-in. Recommendation: use the toolkit's.

Footprint

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

  • .pds-composer__field has overflow: hidden (and position: 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: a MenuButton or Select popup in actionsStart or actionsEnd, a tooltip. Checked 2026-11-20 in Storybook (DOM, not by eye): the MenuButton menu and the bare Select listbox open without error in both the default and the compact variant, and each renders outside the field element, so neither is clipped by overflow: hidden. A custom popup that does not portal will clip. A chip in fieldHeader whose remove button sits outside its tile (Chat Attachment) can be cut at the field edge.
  • position: absolute parts inside the field: the drop label overlay (inset: 0, z-index: 1, pointer-events: none) and the visually hidden live region.
  • .pds-composer__above-field is outside the field border (a grey bar on the top edge with a --pds-spacing-xs inline margin and no bottom border), so the component is taller than the field alone.
  • Resizing: resize: vertical is 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 outline on the field (offset 0), 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 Textarea extension. Recommendation: keep (see above).
  • Copied pds-input* markup. Recommendation: replace with InputLabel and InputMessage in the port.
  • label and id are required, as on Textarea. Recommendation: keep.
  • textareaProps spread 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 dropLabel per surface, or accept the double announcement.
  • Local mergeClasses and the local hook folder. Recommendation: use the toolkit's mergeClasses; port useFileDrop to src/utilities/hooks/.
  • Drop label type. Uses the pds-copy-s class. The textarea still sets family, size and line height from tokens because no pds-copy-* class has the lh-l line 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 in src/components/inputs/input-utilities.tsx; not exported from src/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-s in typography-styles.css, visually-hidden in a11y.css). The others were not individually grepped: not verified.
  • Tokens used: all --pds-* names are in the package's design-token CSS (check:tokens passes). 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/ has useBreakpoint, 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 (the fieldHeader samples), so it does not block the component.
  • Marked ready: IconButton (its primary variant and isWorking are the Send button; they use Spinner and the stop icon in the Icon wrapper), MenuButton, Icon and Button.
  • Port order: see docs/PORT-ORDER.md (node scripts/port-order.mjs --needs=Composer prints 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