Logo
  • Documentation
  • Components
  • New Component Request
GitHub
GitHub
    Treon Studio
    Discord
    Twitter

    Welcome

    Introduction
    Components
    Contributors
    Installation
    Roadmap
    Status - Beta

    Components

    Author TooltipCalendar Event CardCode BlockComponent Preview TooltipChat ComposerEmail Compose CardFile DropzoneFile PreviewGitHub Stars ButtonGoal CardHolo CardKnowledge GraphLink PreviewiOS Message BubblesModel SelectorNavbar MenuNested MenuNotification CardPricing CardRaised ButtonSearch Results TabsSlash Command DropdownTodo ItemTwitter CardWeather CardWorkflow Card

    Form Inputs

    Async Select
    Button
    Button Group
    Checkbox
    Color Picker
    Combobox
    Hierarchical Select
    Input
    Input Base
    Input O T P
    Mask Input
    Multi Select
    Number Input
    Radio Card Group
    Radio Group
    Range Slider
    Search Input
    Segmented Button
    Select
    Slider
    Switch
    Tag Input
    Textarea
    Voice Input

    Layout

    Aspect Ratio
    Card
    Card Icons
    Card Input
    Collapsible
    Divider
    Grid
    Island
    Panel
    Portal
    Resizable
    Scroll Area
    Scroll Shadow
    Separator
    Spacer
    Visually Hidden
    Visually Hidden Input

    Navigation

    Breadcrumb
    Context Menu
    Dropdown Menu
    Menu
    Navbar
    Pagination
    Sidebar
    Steps
    Tab Navigation
    Tabs

    Feedback

    Alert
    Banner
    Callout
    Circular Progress
    Empty State
    Error Message
    Error Page
    Loader Inline
    Loader Screen
    Progress
    Progress Bar
    Skeleton
    Spinner
    Status Dot
    Toast
    Toaster
    Tooltip
    Top Banner
    Tour

    Data Display

    Advanced Table
    Badge
    Badge Overflow
    Data Table
    Description List
    Listbox
    Table
    Tag
    Timeline
    Tree
    Virtualized

    Overlays

    Alert Dialog
    Dialog
    Dialog Stack
    Drawer
    Hover Card
    Popover

    Charts

    Area Chart
    Bar Chart
    Bar List
    Category Bar
    Combo Chart
    Comparison
    Conditional Bar Chart
    Contribution Graph
    Radar Chart

    Calendars

    Attendance Calendar
    Calendar
    Date Picker
    Date Time Field
    Full Calendar
    Gantt
    Mini Calendar
    Schedule
    Schedule Grid
    Time Field

    Typography

    Code
    Code Block
    Control Help
    Control Label
    Field
    Heading
    Kbd
    Label
    Link
    Markdown
    Rich Text Editor
    Snippet
    Text

    Media

    Avatar
    Avatar Group
    Deck
    Document Preview
    File List
    File Upload
    Glimpse
    Image
    Image Crop
    Image Zoom
    Photo Gallery
    Profile Picture
    Q R Code
    Q R Scanner

    User

    Discussion
    Rating
    Testimonial
    User
    User Card

    Interactive

    Accordion
    Action Bar
    Command
    Copy Button
    Cursor
    Emoji Picker
    Fade
    Inline Edit
    Kanban
    Marquee
    Orbit
    Ripple
    Sortable

    Specialized

    App Header
    Bulk Grade Input
    Credit Card
    Footer
    Level Picker
    Notification Card
    Password Strength
    Payment Method
    Pricing Table
    Sandbox
    Stat Card
    Ticker
    Usage Card
    Wizard
    DocsComponents

    Chat Composer

    A chat message input component with file attachments, auto-growing textarea, and tool integration support.

    Made with ❤️ byTreon Studio.Source code available onGitHub

    On This Page

    • Installation
    • Usage
    • Basic Usage
    • With Tools
    • With Context Menu
    • With File Attachments
    • Props
    • Composer
    • Tool
    • ComposerContextOption
    • UploadedFile
    • Features
    Website screenshot
    Meet Bungas
    Your open-source, proactive personal AI assistant with 200+ integrations. Bungas combines todos, goals, calendar, and email into one system, turns tasks into automated workflows, and completes work instead of just tracking it. Open-source and self-hostable with support for custom automations and multi-step workflows.
    /for tools

    Usage in Gaia

    The brain of the app. Handles everything: text, files, slash commands, and tool execution.

    With Attached Files

    document.pdf

    PDF
    screenshot.png

    data.json

    JSON
    /for tools

    Installation

    npx shadcn@latest add https://bungas.treonstudio.com/r/composer.json

    Usage

    Basic Usage

    import { Composer } from "@/components/ui/composer";
     
    export default function Chat() {
      return (
        <Composer
          placeholder="What can I do for you today?"
          onSubmit={(message, files) => {
            console.log("Message:", message);
            console.log("Files:", files);
          }}
        />
      );
    }

    With Tools

    Integrate with the SlashCommandDropdown by providing tools:

    import { Composer, Tool } from "@/components/ui/composer";
     
    const tools: Tool[] = [
      {
        name: "web_search",
        category: "search",
        description: "Search the web for information",
      },
      {
        name: "image_generation",
        category: "creative",
        description: "Generate images from text descriptions",
      },
    ];
     
    export default function ChatWithTools() {
      return (
        <Composer
          tools={tools}
          onToolSelect={(tool) => {
            console.log("Selected tool:", tool);
          }}
          onSubmit={(message) => {
            console.log("Sent:", message);
          }}
        />
      );
    }

    With Context Menu

    Add a dropdown to the plus button with custom options:

    import { Composer, ComposerContextOption } from "@/components/ui/composer";
    import { HugeiconsIcon, AttachmentIcon, Image01Icon } from "@/components/icons";
     
    const contextOptions: ComposerContextOption[] = [
      {
        id: "attach",
        label: "Attach Files",
        description: "Upload documents or images",
        icon: <HugeiconsIcon icon={AttachmentIcon} size={18} />,
        onClick: () => openFilePicker(),
      },
      {
        id: "image",
        label: "Add Image",
        description: "Upload or generate an image",
        icon: <HugeiconsIcon icon={Image01Icon} size={18} />,
        onClick: () => openImagePicker(),
      },
    ];
     
    export default function ChatWithContext() {
      return (
        <Composer
          contextOptions={contextOptions}
          onSubmit={(message) => console.log(message)}
        />
      );
    }

    With File Attachments

    import { useState } from "react";
    import { Composer, UploadedFile } from "@/components/ui/composer";
     
    export default function ChatWithFiles() {
      const [files, setFiles] = useState<UploadedFile[]>([]);
     
      return (
        <Composer
          attachedFiles={files}
          onRemoveFile={(id) => {
            setFiles((prev) => prev.filter((f) => f.id !== id));
          }}
          onSubmit={(message, files) => {
            console.log("Sending:", message, files);
            setFiles([]);
          }}
        />
      );
    }

    Props

    Composer

    PropTypeDefaultDescription
    placeholderstring"What can I do for you today?"Placeholder text for the input
    onSubmit(message: string, files?: UploadedFile[]) => void-Callback when message is submitted
    onChange(value: string) => void-Callback when input value changes
    disabledbooleanfalseWhether the composer is disabled
    showToolsButtonbooleantrueWhether to show the tools button
    toolsTool[][]Available tools for slash command dropdown
    onToolSelect(tool: Tool) => void-Callback when a tool is selected
    contextOptionsComposerContextOption[]-Options for the plus button dropdown
    onAttachClick() => void-Callback when attach clicked (no options)
    autoFocusbooleanfalseWhether to auto-focus the input
    maxRowsnumber8Maximum rows for the textarea
    defaultValuestring""Initial uncontrolled value
    valuestring-Controlled value
    classNamestring-Additional className for the container
    attachedFilesUploadedFile[][]Attached files to display
    onRemoveFile(id: string) => void-Callback to remove an attached file

    Tool

    PropertyTypeRequiredDescription
    namestringYesTool identifier
    categorystringYesCategory for grouping
    descriptionstringNoDescription shown in dropdown
    iconReactNodeNoCustom icon for the tool

    ComposerContextOption

    PropertyTypeRequiredDescription
    idstringYesUnique identifier
    labelstringYesDisplay label
    descriptionstringNoDescription text
    iconReactNodeNoIcon element
    onClick() => voidNoClick handler

    UploadedFile

    PropertyTypeRequiredDescription
    idstringYesUnique file identifier
    namestringYesFile name
    typestringYesMIME type
    urlstringYesFile URL or blob URL
    descriptionstringNoFile description
    isUploadingbooleanNoLoading state

    Features

    • Auto-growing textarea - Expands as you type, up to maxRows
    • File attachments - Display and manage attached files using FilePreview
    • Tools integration - Built-in SlashCommandDropdown for tool selection
    • Context menu - Customizable dropdown for the plus button
    • Keyboard shortcuts - Enter to send, Shift+Enter for new line, Escape to close
    • Primary color - #00bbff for enabled states
    • Accessible - Proper ARIA labels and keyboard navigation