Chatbar
Expandable chat input with auto-resize, file attachments, and drag-and-drop uploads.View source →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
shellUsage
tsxAnatomy
Chatbar is a compound component with the following parts:
tsxProps
Root
Attachment Props
Textarea
Send
AttachmentsRow
AttachTrigger
Types
ChatbarAttachment
tsxChatbarApi
tsxVariants
Use the variant prop to set chatbar style.
Classic
Elevated with shadow for maximum visual impact and prominent chat interfaces.
tsxSurface
Subtle border with background fill. The default variant for most contexts.
tsxSoft
Colored background without border for accent-colored interfaces.
tsxOutline
Border only, no background fill for minimal visual weight.
tsxGhost
Minimal styling with background only on hover/focus for utility contexts.
tsxSizes
Set size for component density: 1 (compact), 2 (standard), 3 (prominent).
Size 1
For compact interfaces like inline replies or comment sections.
tsxSize 2
For standard chat interfaces. The default size.
tsxSize 3
For prominent AI chat experiences and hero sections.
tsxColors
Use the color prop to set the accent color for focus states and the send button. Use highContrast on the Send button for maximum visibility.
tsxMaterial
Use the material prop for translucent surfaces over complex backgrounds.
Theme
Chatbar automatically inherits the theme's material setting:
tsxCustom
Override the theme's material for specific effects:
tsxStates
Disabled
Disables all interactions including text input and file uploads.
tsxRead Only
Allows viewing and selection but prevents editing.
tsxExpansion
The expandOn prop controls when the chatbar expands from compact to full height.
Focus
Expand when the textarea receives focus:
tsxOverflow
Expand when content exceeds one line:
tsxBoth
Expand on either focus or overflow. The default behavior:
tsxNone
Never auto-expand; control manually via open prop:
tsxAttachments
File Picker
Use AttachTrigger with asChild to create a custom file picker button:
tsxDrag and Drop
Dropzone is enabled by default. Files can be dropped anywhere on the chatbar with visual feedback:
tsxPaste to Attach
Paste images or files directly from clipboard:
tsxCustom Rendering
Override the default attachment tile renderer:
tsxSend Mode
Control when the send button appears with sendMode.
When Dirty
Show send button only when there's content or attachments. The default:
tsxAlways
Always show the send button:
tsxNever
Never show the send button. Use with submitOnEnter:
tsxImperative API
Use apiRef for programmatic control:
tsxData Attributes
The Root component exposes data attributes for custom styling:
Accessibility
Chatbar provides comprehensive accessibility through semantic markup, keyboard navigation, and screen reader support.
Keyboard Navigation
- Enter - Submit message (when
submitOnEnteris enabled) - Shift+Enter - Insert new line
- Tab - Navigate between interactive elements
- Escape - Blur the textarea
ARIA Attributes
aria-expandedon root reflects open/closed statearia-labelrequired on Textarea for accessible namerole="list"on attachments containerrole="listitem"on individual attachments
Screen Readers
- Textarea requires
aria-labeloraria-labelledby - Attachments announce file name and size
- Remove buttons announce the file being removed
- Drop overlay announces when files can be dropped
Focus Management
- Clicking anywhere on chatbar focuses the textarea
- Focus remains within chatbar during file dialog
- Blur behavior respects active file dialogs
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