Chatbar
Expandable chat input with auto-resize, file attachments, and drag-and-drop uploads.This component's API and documentation are under review and may change. Use with caution in production.
Use Chatbar to create rich messaging experiences with expandable text areas, file attachments, and intuitive submission flows. Designed for AI chat interfaces, customer support, and collaborative applications.
Playground
Installation
Usage
Anatomy
Chatbar is a compound component with the following parts:
Props
Root
Attachment Props
Textarea
Textarea does not accept rows. Its height is driven by minLines and maxLines on Root.
Send
AttachmentsRow
AttachTrigger
AttachTrigger is disabled while Root is disabled or readOnly.
Types
Types are exported on the Chatbar namespace. Use them as Chatbar.X:
Available types: ChatbarApi, ChatbarAttachment, ChatbarAttachmentStatus, ChatbarAttachmentRejection, ChatbarRejectReason, ChatbarSubmitPayload, ChatbarSendMode, ChatbarExpandOn, and the part props types (ChatbarRootProps, ChatbarTextareaProps, ChatbarInlineSlotProps, ChatbarAttachmentsRowProps, ChatbarAttachmentProps, ChatbarAttachTriggerProps, ChatbarRowProps, ChatbarRowSlotProps, ChatbarSendProps).
ChatbarAttachment
For images, url is an object URL. Chatbar revokes it when the attachment is removed. When a submit clears the chatbar, you own the URLs in the payload and should revoke them with URL.revokeObjectURL when done. If the chatbar is not cleared, Chatbar keeps ownership.
ChatbarSubmitPayload
ChatbarAttachmentRejection
ChatbarApi
Variants
Use the variant prop to set chatbar style.
Classic
Elevated with shadow for maximum visual impact and prominent chat interfaces.
Surface
Subtle border with background fill. The default variant for most contexts.
Soft
Colored background without border for accent-colored interfaces.
Outline
Border only, no background fill for minimal visual weight.
Ghost
Minimal styling with background only on hover/focus for utility contexts.
Sizes
Set size for component density: 1 (compact), 2 (standard), 3 (prominent).
Size 1
For compact interfaces like inline replies or comment sections.
Size 2
For standard chat interfaces. The default size.
Size 3
For prominent AI chat experiences and hero sections.
Colors
Use the color prop (any accent color) to set the accent color for focus states and the send button. With color="gray" the send button fills with step 12 on its own.
Material
Use the material prop for translucent surfaces over complex backgrounds.
Theme
Chatbar automatically inherits the theme's material setting:
Custom
Override the theme's material for specific effects:
States
Disabled
Blocks text editing, submitting, and every attach path: trigger, paste, drop and apiRef. AttachTrigger is disabled and attachment remove buttons are hidden.
Read Only
Allows viewing and selection. Blocks editing, submitting and adding attachments, the same as disabled. Remove buttons are hidden.
Expansion
The expandOn prop controls when the chatbar expands from compact to full height.
Focus
Expand when the textarea receives focus:
Overflow
Expand when content exceeds one line:
Both
Expand on either focus or overflow. The default behavior:
None
Never auto-open, even when a file is attached, and never auto-collapse on blur. Control it with the open prop:
Attachments
File Picker
Use AttachTrigger with asChild to create a custom file picker button. Its accept overrides Root accept for files picked through it:
Drag and Drop
Dropzone is enabled by default. Files can be dropped anywhere on the chatbar with visual feedback. The same accept, multiple, maxFileSize and maxAttachments rules apply to pick, paste and drop:
Paste to Attach
Paste images or files directly from the clipboard. A pasted file is attached once. pasteAccept replaces accept for paste. If every pasted file is rejected, the normal text paste still happens.
Custom Rendering
Override the default attachment tile renderer:
Send Mode
sendMode controls only whether the Send button is visible. Submitting, with Enter or Send, always requires text or at least one attachment. A hidden Send is aria-hidden and not focusable.
When Dirty
Show Send only when there is text or an attachment. The default:
Always
Always show Send. With nothing to send it is visible but disabled:
Never
Never render Send. Pair with submitOnEnter so Enter submits:
Imperative API
Use apiRef for programmatic control. openFilePicker() works without an AttachTrigger and with dropzone={false}, and does nothing when the chatbar is disabled or read-only.
Data Attributes
The Root component exposes data attributes for custom styling:
Accessibility
Chatbar provides accessibility through semantic markup, keyboard support and live announcements.
Keyboard Navigation
- Enter - Submit when
submitOnEnteris on. A plain Enter never inserts a newline, even with nothing to send - Shift+Enter - Insert a new line
- Tab - Move between interactive elements. A hidden Send is skipped
- Enter used to confirm IME composition is ignored
ARIA Attributes
aria-labeloraria-labelledbyrequired on Textarea for an accessible namerole="list"on the attachments container androle="listitem"on each attachment- Remove buttons are labelled "Remove" plus the file name
- A hidden Send carries
aria-hidden
Screen Readers
- A polite live region announces attachments added, rejected and removed
- The live region announces a hint while files are dragged over the chatbar
- Image tiles carry visually hidden name, size and status
Focus Management
- Clicking a non-interactive area of the chatbar focuses the textarea
- After removing an attachment, focus moves to the neighbouring remove button, or back to the textarea
- Blur collapse is held off while the file dialog is open
Motion
- Layout animations respect
prefers-reduced-motion
Changelog
Added
- Compound component architecture with Root, Textarea, Send, AttachmentsRow, AttachTrigger, Row, RowStart, RowEnd, InlineStart, InlineEnd
- Controlled and uncontrolled value, open, and attachments states
- File picker, drag-and-drop, and paste-to-attach support
- Auto-resizing textarea with configurable line limits
- Imperative API via
apiReffor programmatic control - Multiple visual variants: surface, outline, classic, ghost, soft
- Material support for translucent surfaces
- Comprehensive accessibility with ARIA attributes and keyboard navigation
- Exported types on the
Chatbarnamespace:ChatbarApi,ChatbarAttachment,ChatbarAttachmentRejection,ChatbarRejectReason,ChatbarSubmitPayload,ChatbarSendMode,ChatbarExpandOn, and part props types - Polite live region for attachment and drag-over announcements
Changed
- Root no longer accepts
asChild - Root no longer sets
aria-expanded sendModecontrols Send visibility onlySend clearOnSenddefaults to RootclearOnSubmitpasteAcceptreplacesacceptfor pastecoloris typed as an accent color andradiusas'none' | 'small' | 'medium' | 'large' | 'full'
Removed
highContraston Send. Gray fills with step 12 on its own.
Fixed
sendMode="never"withsubmitOnEnternow submits- Empty messages with no attachments no longer submit
- Clearing now calls
onValueChange('')for a controlled value - Plain Enter with
submitOnEnterno longer inserts a newline; IME composition Enter is ignored disabledandreadOnlyblock every attach path and hide remove buttonsexpandOn="none"no longer opens on attach or collapses on blurmultiple={false}applies to paste and drop- Pasted files attach once, and text paste still happens when all pasted files are rejected
apiRef.openFilePicker()works without an AttachTrigger and withdropzone={false}- Image preview URLs are revoked on removal
© 2026 Kushagra Dhawan. Licensed under MIT. GitHub.