跳到正文
Linasan UI

Combobox 组合框

可搜索的下拉选择,单选或多选,列表虚拟滚动。

  • 按 label、hint 和 value 搜索,支持 group 分组。
  • 列表虚拟滚动:上万个选项也只渲染看得见的几十行;关掉再打开回到上次的位置。
  • 键盘:↑↓ 移动、Enter 选择、PageUp / PageDown 翻页。
  • 远程数据:onSearch 接管搜索,onReachEnd + loading 翻页追加。

安装

pnpm dlx shadcn@latest add https://docs.linasan.cn/r/combobox.json

第一次装本站的组件前先在项目里执行一次 shadcn init,详见 安装。

用法

import { Combobox } from '@/components/form/combobox';

<Combobox options={options} value={v} onChange={setV} />
<Combobox multiple max={5} options={options} value={vs} onChange={setVs} />

属性

属性

类型

本页目录