输入框
基于 zw-input 基础组件构建的样式化文本输入框。
@zeus-web/input数据录入zweb add input自动生成
交互演示
源码
请选择与你的应用框架匹配的入口。
html
<script type="module">
import '@zeus-web/input/wc/auto'
</script>
<zw-input type="email" placeholder="name@example.com"></zw-input>tsx
import { Input } from '@zeus-web/input/react'
export function InputExample() {
return <Input type="email" placeholder="name@example.com" />
}vue
<script setup lang="ts">
import { Input } from '@zeus-web/input/vue'
</script>
<template>
<Input type="email" placeholder="name@example.com" />
</template>添加
bash
zweb add input导入
样式化 Registry 组件:
tsx
import { Input } from '@/components/ui/input'基础组件 React 包装器:
tsx
import { Input } from '@zeus-web/input/react'Web Component 入口:
ts
import '@zeus-web/input/wc/auto'属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
value | string | - | 受控输入值。 |
defaultValue | string | - | 非受控模式的初始值。 |
type | InputType可选值: text, email, password, search, tel, url, number | text | 原生输入类型。 |
placeholder | string | - | 占位文本。 |
disabled | boolean | - | 禁用输入交互。 |
id | string | - | 原生输入框的 id 属性。 |
autocomplete | string | - | 原生输入框的 autocomplete 属性。 |
ariaLabel | string | - | 无可见标签输入框的无障碍标签。 |
ariaDescribedby | string | - | 额外无障碍说明的 ID 引用。 |
ariaErrormessage | string | - | 无障碍错误消息的 ID 引用。 |
事件
| 事件 | React 属性 | 详情 | 说明 |
|---|---|---|---|
value-change | onValueChange | value: string, nativeEvent: Event | 输入值变化时触发。 |
插槽
| 插槽 | 说明 |
|---|---|
prefix | 原生输入框之前的内容。 |
suffix | 原生输入框之后的内容。 |
样式
使用 Tailwind: 是
主题变量:
border-inputring-ringtext-muted-foreground
内部选择器:
[&_[part=root]][&_[data-slot=input]]
Registry
Registry 源码:可用。
添加命令: zweb add input
类型: component
依赖:
@zeus-web/input
Registry 依赖:
cnglobals
文件:
templates/react/input.tsx→components/ui/input.tsxtemplates/vue/input.vue→components/ui/input.vue
AI 使用规则
建议:
- 文本类表单字段使用 Input。
- 需要 Zeus 自定义事件时使用 onValueChange。
避免:
- 不要只在宿主元素上设置占位符或禁用状态样式。
- 不要假定原生 input 就是自定义元素本身。
示例
React 样式化用法
tsx
import { Input } from '@/components/ui/input'
export function Example() {
return <Input placeholder="Email" type="email" />
}