Agent 输入台

New

AI agent 聊天输入台组件族:上下文 chips、权限 chip、内置分段推理力度滑杆的模型选择器,以及可变形的发送/停止按钮,并带添加菜单与语音听写态。

spec.md12 KB
mockup.png1.2 MB
64K / 200K

安装

用 shadcn CLI 添加,或手动复制源码。

$ bunx --bun shadcn add @uilab/agent-composer

API 参考

Composer

className?
string

ComposerContextBar

className?
string

ComposerChip

icon?
ReactNode
hoverIcon?
ReactNode

Swapped in for `icon` on hover/focus (opacity crossfade, no layout shift). Only meaningful on interactive chips — pair it with `onClick`.

onClick?
(() => void)

Makes the chip a `<button>` with a hover pill surface.

title?
string

Native tooltip, e.g. "Change project".

className?
string

ComposerTextarea

value
string
onChange
(next: string) => void
placeholder?
string
onSubmit?
(() => void)

Fires when Enter is pressed without Shift — the caller owns what "submit" means.

aria-label?
string
className?
string

ComposerToolbar

className?
string

ComposerIconButton

aria-label
string
onClick?
(() => void)
className?
string
disabled?
boolean

ComposerAccessChip

icon?
ReactNode
tone?
"default" | "warning"

"warning" (default) reads as an orange access-level alert; "default" is muted.

warning
onClick?
(() => void)
className?
string

ComposerModelPicker

label
ReactNode

Trigger content, e.g. `"5.6 · High"` — a chevron is appended automatically.

open?
boolean
onOpenChange?
((open: boolean) => void)
className?
string

ComposerMenuButton

icon?
ReactNode

16px icon; alone it renders the circular icon-button look.

label?
ReactNode

Optional text label; with it the trigger becomes a pill like the model-picker trigger (no chevron).

aria-label
string
align?
"end" | "start"

Panel anchor edge — defaults to "start" (left-aligned above the trigger).

start
open?
boolean
onOpenChange?
((open: boolean) => void)
className?
string

ComposerMenuSection

title?
ReactNode
className?
string

ComposerMenuItem

icon?
ReactNode
description?
ReactNode

Muted one-liner rendered inline after the name, truncated when tight.

onSelect?
(() => void)
className?
string

ComposerSendButton

running?
boolean
false
disabled?
boolean
onClick?
(() => void)
aria-label?
string
className?
string

ComposerDictation

seconds
number

Elapsed recording time, owned by the caller; formatted as m:ss.

onStop?
(() => void)
className?
string
aria-label?
string

Label for the stop button — defaults to "Stop dictation".

ComposerAttachments

className?
string

ComposerAttachmentChip

icon?
ReactNode

14px icon, e.g. `<FileText className="h-3.5 w-3.5" />`.

name
ReactNode
meta?
ReactNode

Muted trailing detail, e.g. a file size.

onRemove?
(() => void)
className?
string

ComposerContextGauge

used
number
limit
number
formatLabel?
((used: number, limit: number) => ReactNode)

Defaults to a K-abbreviated "32K / 200K" readout.

className?
string

ComposerAutonomyDial

value
number
onChange
(next: number) => void
labels?
string[]

Step labels — length sets the number of tiers (defaults to 4).

["Suggest only", "Ask first", "Scoped auto", "Full auto"]
aria-label?
string
className?
string
disabled?
boolean
false

ComposerEffortSlider

value
number
onChange
(next: number) => void
labels?
string[]

Step labels — length sets the number of segments (defaults to 5).

["Minimal", "Low", "Standard", "High", "Max"]
aria-label?
string
className?
string
disabled?
boolean
false

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.