Skip to content

Sender 输入框 ​

用于聊天的输入框组件。

何时使用 ​

需要构建一个对话场景下的输入框

代码演示 ​

基本用法 ​

提交用法 ​

语音输入 ​

语音输入图标 ​

自定义语音输入 ​

自定义按钮 ​

展开面板 ​

引用 ​

自定义底部内容 ​

使用 footer 自定义底部内容。

自定义输入框 ​

使用 components.input 自定义输入框。

调整样式 ​

黏贴文件 ​

聚焦 ​

API ​

SenderProps ​

属性说明类型默认值版本
actions自定义按钮,当不需要默认操作按钮时,可以设为 actions={false}VNode | (oriNode, info: { components: ActionsComponents }) => VNode--
allowSpeech是否允许语音输入boolean | SpeechConfigfalse-
classNames样式类名见下--
components自定义组件,input默认为Input.TextArea,确保在自定义输入组件时,按照 Input.TextArea 实现所有必要的 props,以避免功能不全。Record<'input', ComponentType>--
defaultValue输入框默认值string--
disabled是否禁用booleanfalse-
loading是否加载中booleanfalse-
header头部面板VNode | () => VNode--
prefix前缀内容VNode | () => VNode--
footer底部内容ReactNode | (info: { components: ActionsComponents }) => ReactNode--
readOnly是否让输入框只读booleanfalse-
rootClassName根元素样式类string--
styles语义化定义样式见下--
submitType提交模式SubmitTypeenter | shiftEnter-
value(v-model)输入框值string--
onSubmit点击发送按钮的回调(message: string) => void--
onChange输入框值改变的回调(value: string, event?: FormEvent | ChangeEvent ) => void--
onCancel点击取消按钮的回调() => void--
onPasteFile黏贴文件的回调(firstFile: File, files: FileList) => void--
autoSize自适应内容高度,可设置为 true | false 或对象:{ minRows: 2, maxRows: 6 }boolean | { minRows?: number; maxRows?: number }{ maxRows: 8 }-
typescript
type SpeechConfig = {
  // 当设置 `recording` 时,内置的语音输入功能将会被禁用。
  // 交由开发者实现三方语音输入的功能。
  recording?: boolean;
  onRecordingChange?: (recording: boolean) => void;
  audioIcon?: ButtonProps['icon'] | VNode;
  audioDisabledIcon?: ButtonProps['icon'] | VNode;
  audioRecordingIcon?: ButtonProps['icon'] | VNode;
};
typescript
type ActionsComponents = {
  SendButton: InstanceType<ButtonProps>;
  ClearButton: InstanceType<ButtonProps>;
  LoadingButton: InstanceType<ButtonProps>;
  SpeechButton: InstanceType<ButtonProps>;
};

Sender Slots ​

插槽名说明类型
header头部面板-
prefix前缀内容_
actions操作按钮{ ori: VNode; info: { components: { SendButton: InstanceType<Button>; ClearButton: InstanceType<Button>; LoadingButton: InstanceType<Button>; SpeechButton: InstanceType<Button>; } } }
footer底部内容{ info: { components: { SendButton: InstanceType<Button>; ClearButton: InstanceType<Button>; LoadingButton: InstanceType<Button>; SpeechButton: InstanceType<Button>; } } }

Sender Ref ​

属性说明类型默认值版本
nativeElement外层容器HTMLDivElement--
focus获取焦点(option?: { preventScroll?: boolean, cursor?: 'start' | 'end' | 'all' })--
blur取消焦点() => void--

Sender.Header ​

属性说明类型默认值版本
children面板内容VNode--
closable是否可关闭booleantrue-
forceRender强制渲染,在初始化便需要 ref 内部元素时使用booleanfalse-
open是否展开boolean--
title标题VNode--
onOpenChange展开状态改变的回调(open: boolean) => void--

Semantic DOM ​

  • prefix
    前缀
  • input
    输入框
  • actions
    操作列表
Header
Content
  • header
    头部
  • header-content
    头部内容
  • footer
    尾部

主题变量(Design Token) ​

贡献者 ​

贡献者

正在加载贡献者信息...