Composer
gaia/composerFreeComponent
A chat message input component with file attachments, auto-growing textarea, and tool integration support.
Install it
npx shadcn@latest add https://ui.heygaia.io/r/composer.jsonSource
1"use client";23import type { FC, ReactNode } from "react";4import { useCallback, useEffect, useRef, useState } from "react";5import {6 ArrowUp02Icon,7 HugeiconsIcon,8 PlusSignIcon,9 ToolsIcon,10} from "@/components/icons";11import { cn } from "@/lib/utils";12import {13 FilePreview,14 type UploadedFile,15} from "@/registry/new-york/ui/file-preview";16import {17 SlashCommandDropdown,18 type SlashCommandMatch,19 type Tool,20} from "@/registry/new-york/ui/slash-command-dropdown";2122// Re-export types for convenience23export type { Tool, SlashCommandMatch, UploadedFile };2425export interface ComposerContextOption {26 id: string;27 label: string;28 icon?: ReactNode;29 description?: string;30 onClick?: () => void;31}3233export interface ComposerProps {34 /** Placeholder text for the input */35 placeholder?: string;36 /** Callback when message is submitted */37 onSubmit?: (message: string, files?: UploadedFile[]) => void;38 /** Callback when input value changes */39 onChange?: (value: string) => void;40 /** Whether the composer is disabled */41 disabled?: boolean;42 /** Whether to show the tools button */43 showToolsButton?: boolean;44 /** Callback when a tool is selected from slash command dropdown */45 onToolSelect?: (tool: Tool) => void;46 /** Available tools for the slash command dropdown */47 tools?: Tool[];48 /** Callback when attach button is clicked (if no context options) */49 onAttachClick?: () => void;50 /** Context options for the plus button dropdown */51 contextOptions?: ComposerContextOption[];52 /** Whether to auto-focus the input */53 autoFocus?: boolean;54 /** Maximum rows for the textarea */55 maxRows?: number;56 /** Initial value */57 defaultValue?: string;58 /** Controlled value */59 value?: string;60 /** Additional className for the container */61 className?: string;62 /** Attached files to display */63 attachedFiles?: UploadedFile[];64 /** Callback to remove an attached file */65 onRemoveFile?: (id: string) => void;66 /** Whether the composer is in loading state */67 isLoading?: boolean;68}6970// Primary color matching GAIA: #00bbff71const PRIMARY_COLOR = "#00bbff";7273export const Composer: FC<ComposerProps> = ({74 placeholder = "What can I do for you today?",75 onSubmit,76 onChange,77 disabled = false,78 showToolsButton = true,79 onToolSelect,80 tools = [],81 onAttachClick,82 contextOptions,83 autoFocus = false,84 maxRows = 8,85 defaultValue = "",86 value,87 className,88 attachedFiles = [],89 onRemoveFile,90 isLoading = false,91}) => {92 const [inputValue, setInputValue] = useState(defaultValue);93// … truncated
What it pulls in
Other registry items
Files it writes
More from gaia
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Area Chartarea-chart | gaia | Components | Free | 1 dep | |
| Author Tooltipauthor-tooltip | gaia | Components | Free | no deps | |
| Bar Chartbar-chart | gaia | Components | Free | 1 dep | |
| Email Compose Cardemail-compose-card | gaia | Components | Free | no deps | |
| Gauge Chartgauge-chart | gaia | Components | Free | 1 dep | |
| GitHub Stars Buttongithub-stars-button | gaia | Components | Free | 1 dep | |
| Holo Cardholo-card | gaia | Components | Free | 1 dep · 2 files | |
| Iconsicons | gaia | Components | Free | 2 deps |
