No.237 · AI & Chat
Prompt Composer
A chat composer where attached files tuck into its top edge like tabs in a folder — they rise from behind it when added and sink back when removed. Send turns into stop while the reply streams.
The prompt
Written for the variant you picked above: Paper
Design a chat composer (think a calm Claude/ChatGPT-style input) whose attachments are part of the object. The composer body is a 22px-radius surface with a hairline ring and soft shadow; a textarea that grows with its content up to ~8 lines (Enter sends, Shift+Enter breaks); a tools row with a round attach button, a 'Search' toggle chip, a model chip whose label rolls up when it changes, a mic button, and a round ink send button. Attached files are not chips inside the box: they are tabs standing on the composer's top edge, in the same surface colour, with rounded top corners, a hairline on their top and sides, and small inverse-radius corners (radial-gradient pseudo-elements) so each tab grows out of the edge like a folder tab. Each tab has a coloured three-letter type glyph (PDF / CSV / IMG / </>), a truncated file name and a remove ×. A new tab rises from behind the edge (translateY 100% → 0, 520ms expo-out, staggered 50ms); a removed tab sinks back behind it (360ms ease-in) before leaving the DOM. The tabs row animates its height open, and the body's top-left corner tightens when tabs are present. Files come from the picker, drag-and-drop or paste. Sending clears the text and sinks the tabs; the send button's arrow lifts out and a stop square scales in while a thin accent arc turns around the button until the reply finishes (click it to stop). Ship a warm paper theme (ivory, clay accent) and a night theme. Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Type and press Enter (Shift+Enter for a new line); attach via +, drag-and-drop or paste; remove a file with its ×; while generating, the send button stops the reply. Motion: Tabs rise 520ms / sink 360ms from behind the top edge; textarea auto-grows; model label rolls 360ms; send → stop morph with a 1.1s turning arc. Accessibility: Labelled textarea; tabs are a list with 'Remove file' buttons; icon buttons have labels; model and search chips expose state (aria-pressed / label); 'Generating a reply' is announced. Reduced motion makes every transition instant. Responsive behavior: Fluid up to 44rem; tabs truncate their names and cap at six. Touch: Every control is a real button at 34–38px; the file picker works on mobile and pasted images attach. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Type and press Enter (Shift+Enter for a new line); attach via +, drag-and-drop or paste; remove a file with its ×; while generating, the send button stops the reply.
- Motion
- Tabs rise 520ms / sink 360ms from behind the top edge; textarea auto-grows; model label rolls 360ms; send → stop morph with a 1.1s turning arc.
- Accessibility
- Labelled textarea; tabs are a list with 'Remove file' buttons; icon buttons have labels; model and search chips expose state (aria-pressed / label); 'Generating a reply' is announced. Reduced motion makes every transition instant.
- Responsive
- Fluid up to 44rem; tabs truncate their names and cap at six.
- On touch
- Every control is a real button at 34–38px; the file picker works on mobile and pasted images attach.