SxCheckbox (复选框)
二元状态选择组件。用于切换开启/关闭状态或在列表中选择多个项。对齐 Microsoft Fluent UI Blazor Checkbox (v4.13.2) 的 API 结构,并说明 NextUI 当前实现状态。
使用场景
约束说明
Indeterminate 仅视觉表示,用户交互后会自动清除。
ReadOnly 与 Disabled 都会阻止变更。
API
Parameters (参数)
| 状态 |
参数名 |
类型 |
默认值 |
描述 |
| Implemented |
Value |
bool |
false |
复选框当前状态。 |
| Implemented |
Label |
string? |
null |
选项旁显示的描述文字。 |
| Implemented |
Indeterminate |
bool |
false |
半选状态。 |
| Implemented |
ReadOnly |
bool |
false |
是否为只读。 |
| Implemented |
Required |
bool |
false |
是否必填。 |
| Implemented |
Name |
string? |
null |
元素 name。 |
| Implemented |
Autofocus |
bool |
false |
页面加载时自动获取焦点。 |
| Implemented |
AriaLabel |
string? |
null |
辅助功能:aria-label。 |
| Implemented |
Id (继承) |
string? |
null |
组件的物理 Id。 |
| Implemented |
Class (继承) |
string? |
null |
自定义 CSS 类名。 |
| Implemented |
Style (继承) |
string? |
null |
自定义样式。 |
| Implemented |
Title (继承) |
string? |
null |
HTML title 属性。 |
| Implemented |
Disabled (继承) |
bool |
false |
是否禁用交互。 |
| Not Implemented |
Loading (继承) |
bool |
false |
加载状态(未应用)。 |
| Implemented |
TabIndex (继承) |
int? |
null |
Tab 顺序。 |
| Implemented |
AccessKey (继承) |
string? |
null |
快捷键。 |
| Implemented |
AdditionalAttributes (继承) |
IEnumerable<KeyValuePair<string, object>>? |
null |
捕获不匹配的 HTML 属性。 |
| Not Implemented |
DisplayName (继承) |
string? |
null |
验证失败时显示的字段名。 |
| Not Implemented |
ValueExpression (继承) |
Expression<Func<bool>>? |
null |
数据绑定验证表达式。 |
Events (事件)
| 状态 |
事件名 |
类型 |
描述 |
| [x] |
OnBlur |
EventCallback<FocusEventArgs> |
失去焦点时触发。 |
| [x] |
OnFocus |
EventCallback<FocusEventArgs> |
获得焦点时触发。 |
| [x] |
ValueChanged (继承) |
EventCallback<bool> |
选中状态改变时触发(支持 @bind-Value)。 |
Methods (方法)
| 状态 |
方法名 |
返回值 |
描述 |
| [x] |
FocusAsync |
ValueTask |
使复选框获得焦点。 |
示例用法
<SxCheckbox @bind-Value="_isAgreed" Label="我已阅读并同意用户协议" />
参考设计 (References)