Skip to content

Input ​

单行文本输入,通过鼠标或键盘输入内容。

使用 ​

ts
import { NxInput } from "@pc-nexus/angular";
ts
import { NxInput } from "@pc-nexus/react";

属性 ​

名称类型必填描述
valuestring当前输入值(表单协议)
placeholderstring占位文案
size'small' | 'medium' | 'large'尺寸,默认 medium
appearance'outline' | 'fill' | 'subtle' | 'ghost'外观,默认 outline
typestring原生 input type,如 text、number、password
readonlyboolean只读,默认 false
disabledboolean禁用,默认 false
maxlengthnumber最大输入长度
minlengthnumber最小输入长度
minnumber | string最小值(常用于 type="number")
maxnumber | string最大值(常用于 type="number")
stepnumber | string步进值(常用于 type="number")
requiredboolean是否必填,默认 false
autofocusboolean自动聚焦,默认 false
idstring元素 id
namestring原生 name

事件 ​

名称类型描述
valueChange(value: string)输入值变化时触发
focus(event: Event)获得焦点时触发
blur(event: Event)失去焦点时触发

示例 ​

Basic ​

通过 value 绑定当前文本,并用 valueChange 监听变化。Angular 可使用 [(value)];React 需配合 onValueChange 更新状态。

Appearance ​

通过 appearance 设置外观,取值可以为 'outline' | 'fill' | 'subtle' | 'ghost'。

Size ​

通过 size 设置尺寸,取值可以为 'small' | 'medium' | 'large'。

Type ​

通过 type 设置原生 input 类型,如 text、number、password。

Limit ​

通过 minlength / maxlength 限制文本长度,或通过 min / max 限制数值范围。

Readonly ​

通过 readonly 设为只读。

Disabled ​

通过 disabled 禁用输入。

举报邮箱:abuse@worktile.com