SxCombobox (组合框)
可输入的下拉选择器。允许用户从列表中选择,或直接输入自定义文本。对齐 Microsoft Fluent UI Blazor Combobox (v4.13.2) 的 API 结构,并说明 NextUI 当前实现状态。
使用场景
- 可搜索的下拉选择
- 数据量较小的自由输入选择
- 支持自定义渲染选项内容
约束说明
Items 为空时不会弹出面板。
Open 受内部控制,仅通过点击箭头或输入触发。
行为说明
- 输入内容会过滤
Items 并自动打开下拉面板。
- 选择项后会更新
Value 并关闭面板。
API
Parameters (参数)
| 状态 |
参数名 |
类型 |
默认值 |
描述 |
| Implemented |
Value |
string? |
null |
当前选中的值或输入的文本。 |
| Implemented |
Items |
IEnumerable<TValue>? |
null |
备选项集合。 |
| Implemented |
OptionTemplate |
RenderFragment<TValue>? |
null |
自定义选项渲染模版。 |
| Implemented |
Label |
string? |
null |
顶部标签文本。 |
| Implemented |
Placeholder |
string? |
null |
占位文案。 |
| Implemented |
Appearance |
SxInputAppearance |
Outline |
视觉风格:Outline, Filled, Stealth。 |
| Not Implemented |
Autocomplete |
ComboboxAutocomplete |
None |
自动完成建议模式(未应用)。 |
| Implemented |
Autofocus |
bool |
false |
页面加载时自动获取焦点。 |
| Implemented |
AriaLabel |
string? |
null |
辅助功能:aria-label。 |
| Implemented |
Open |
bool |
false |
控制下拉面板状态。 |
| Implemented |
Height |
string? |
null |
下拉面板最大高度。 |
| Implemented |
Width |
string? |
null |
锁定组件宽度。 |
| Not Implemented |
Position |
SelectPosition |
Below |
弹出层位置(未应用)。 |
| Implemented |
LabelSelector |
Func<TValue, string>? |
null |
自定义选项文本选择器。 |
| Implemented |
ReadOnly (继承) |
bool |
false |
是否为只读状态。 |
| Implemented |
Required (继承) |
bool |
false |
是否为必填项。 |
| Implemented |
Disabled (继承) |
bool |
false |
是否禁用交互。 |
| Implemented |
Id (继承) |
string? |
null |
组件的物理 Id。 |
| Implemented |
Class (继承) |
string? |
null |
自定义 CSS 类名。 |
| Implemented |
Style (继承) |
string? |
null |
自定义样式。 |
| Implemented |
Title (继承) |
string? |
null |
HTML title 属性。 |
| Not Implemented |
Loading (继承) |
bool |
false |
加载状态(未应用)。 |
| Implemented |
TabIndex (继承) |
int? |
null |
Tab 顺序。 |
| Implemented |
AccessKey (继承) |
string? |
null |
快捷键。 |
| Implemented |
AdditionalAttributes (继承) |
IEnumerable<KeyValuePair<string, object>>? |
null |
捕获不匹配的 HTML 属性。 |
Events (事件)
| 状态 |
事件名 |
类型 |
描述 |
| Implemented |
ValueChanged |
EventCallback<string?> |
值改变时触发。 |
| Implemented |
OpenChanged |
EventCallback<bool> |
下拉面板开合变化。 |
示例
<SxCombobox TValue="string"
Items="_items"
Placeholder="请选择或输入..."
@bind-Value="_value" />
参考设计 (References)