Add files, write a note, and send the draft to see how the composer clears after a successful response.
Chat - Composer with attachments
Build the full headless draft surface with a textarea, hidden file input, helper text, and send action.
This demo isolates the draft area so the interaction model is easy to understand before it is embedded into a larger chat shell.
That is useful because chat composers often look simple but hide a lot of behavior: autosizing, disabled states, IME-safe submit, attachment selection, and helper text.
Composer.RootComposer.TextAreaComposer.AttachButtonComposer.HelperTextComposer.SendButton- attachment flows and IME-safe input behavior
Attachments composer
Key primitives
Composer.Rootfor form submission and shared composer contextComposer.TextAreafor autosizing textarea behavior and IME-safe submitComposer.AttachButtonfor the visible trigger plus hidden file inputComposer.HelperTextfor error or helper messagingComposer.SendButtonfor runtime-aware disabled and submit state
Implementation notes
- Show both text-only and attachment-backed drafts.
- Make the helper text visible through either explicit copy or a runtime error so its role is clear.
- Keep the visual design plain so the hidden file-input relationship is the main lesson.
When to use this pattern
Use this pattern when:
- a product surface needs upload support
- the send action depends on runtime state
- the team needs a clear demo of the headless composer contract
This applies to support chat with screenshots, copilots that accept reference files, and internal tools where users need to attach evidence or export artifacts alongside text.
What to pay attention to
Composer.AttachButtonowns the visible-trigger plus hidden-input relationship, so the page layer does not need attachment plumbing.Composer.HelperTextis the natural place for both authored guidance and runtime error fallback.Composer.TextAreaalready handles the IME and Enter behavior that teams often reimplement by hand.
See also
- Continue with Composer for the reference-level API and behaviors.
- Continue with Slot customization when the default composer structure is correct but the markup needs to match a custom design system.