feat: complete field documentation and TextArea examples
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { Description, Input, Label } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label for="email">邮箱</Label>
|
||||
<Input
|
||||
id="email"
|
||||
aria-describedby="email-description"
|
||||
class="w-64"
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
/>
|
||||
<Description id="email-description">
|
||||
我们不会将你的邮箱分享给任何人。
|
||||
</Description>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Description, Input, Label } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-64 flex-col gap-1">
|
||||
<Label for="workspace-slug">工作区 URL</Label>
|
||||
<Input id="workspace-slug" placeholder="acme" type="text" />
|
||||
<Description id="workspace-slug-hint" class="leading-relaxed tracking-wide">
|
||||
仅支持小写字母和连字符。将用于 app.heroui.com/acme
|
||||
</Description>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { FieldError, Input, Label, TextField } from "@heroui-vue/components";
|
||||
|
||||
const value = ref("jr");
|
||||
const isInvalid = computed(
|
||||
() => value.value.length > 0 && value.value.length < 3,
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField v-model="value" class="w-64" :is-invalid="isInvalid">
|
||||
<Label for="username">用户名</Label>
|
||||
<Input id="username" placeholder="输入用户名" />
|
||||
<FieldError>用户名至少需要 3 个字符</FieldError>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { FieldError, Input, Label, TextField } from "@heroui-vue/components";
|
||||
|
||||
const value = ref("jr");
|
||||
const isInvalid = computed(
|
||||
() => value.value.length > 0 && value.value.length < 3,
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField v-model="value" class="w-64" :is-invalid="isInvalid">
|
||||
<Label for="handle">用户名</Label>
|
||||
<Input id="handle" class="bg-field font-mono" placeholder="至少 3 个字符" />
|
||||
<FieldError class="font-medium">用户名至少需要 3 个字符</FieldError>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label for="name">姓名</Label>
|
||||
<Input id="name" class="w-64" placeholder="输入你的姓名" type="text" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<Label
|
||||
class="text-xs font-semibold tracking-wide text-accent uppercase"
|
||||
for="repo"
|
||||
>
|
||||
仓库
|
||||
</Label>
|
||||
<Input id="repo" class="w-64 bg-field" placeholder="heroui/react" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label, TextField } from "@heroui-vue/components";
|
||||
|
||||
const fieldClass =
|
||||
"rounded-xl border border-border/80 bg-surface shadow-sm ring-1 ring-black/5 transition-[box-shadow,border-color] focus-visible:ring-2 focus-visible:ring-neutral-400/25 dark:ring-white/10 dark:focus-visible:ring-neutral-500/30";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField class="w-full max-w-64 gap-1.5" name="email" type="email">
|
||||
<Label class="font-medium text-neutral-800 dark:text-neutral-100">
|
||||
邮箱
|
||||
</Label>
|
||||
<Input
|
||||
:class="[
|
||||
'text-sm text-neutral-800 placeholder:text-neutral-400 dark:text-neutral-100 dark:placeholder:text-neutral-500',
|
||||
fieldClass,
|
||||
]"
|
||||
placeholder="输入你的邮箱"
|
||||
/>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextArea
|
||||
aria-label="快速项目更新"
|
||||
class="h-32 w-96"
|
||||
placeholder="分享一条简短的项目更新…"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { Description, TextArea } from "@heroui-vue/components";
|
||||
|
||||
const value = ref("");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-96 flex-col gap-2">
|
||||
<TextArea
|
||||
v-model="value"
|
||||
aria-describedby="textarea-controlled-description"
|
||||
aria-label="公告"
|
||||
placeholder="撰写公告…"
|
||||
/>
|
||||
<Description id="textarea-controlled-description">
|
||||
字符数: {{ value.length }} / 280
|
||||
</Description>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { TextArea } from "@heroui-vue/components";
|
||||
|
||||
const fieldClass =
|
||||
"rounded-xl border border-border/80 bg-surface shadow-sm ring-1 ring-black/5 transition-[box-shadow,border-color] focus-visible:ring-2 focus-visible:ring-neutral-400/25 dark:ring-white/10 dark:focus-visible:ring-neutral-500/30";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextArea
|
||||
aria-label="备注"
|
||||
:class="[
|
||||
'h-28 w-full max-w-xs text-sm text-neutral-800 placeholder:text-neutral-400 dark:text-neutral-100 dark:placeholder:text-neutral-500',
|
||||
fieldClass,
|
||||
]"
|
||||
placeholder="添加备注…"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-[400px] space-y-3">
|
||||
<TextArea full-width placeholder="全宽文本域" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Surface, TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Surface class="w-full rounded-3xl p-6">
|
||||
<TextArea
|
||||
class="w-full min-w-[280px]"
|
||||
placeholder="描述你的产品"
|
||||
variant="secondary"
|
||||
/>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import { Label, TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-96 flex-col gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<Label for="textarea-rows-3">简短反馈</Label>
|
||||
<TextArea
|
||||
id="textarea-rows-3"
|
||||
aria-label="简短反馈"
|
||||
placeholder="本周亮点…"
|
||||
:rows="3"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<Label for="textarea-rows-6">详细笔记</Label>
|
||||
<TextArea
|
||||
id="textarea-rows-6"
|
||||
aria-label="详细笔记"
|
||||
placeholder="写下完整的会议记录…"
|
||||
:rows="6"
|
||||
style="resize: vertical"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-[280px] flex-col gap-2">
|
||||
<TextArea full-width placeholder="主要文本域" variant="primary" />
|
||||
<TextArea full-width placeholder="次要文本域" variant="secondary" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Description,
|
||||
Input,
|
||||
Label,
|
||||
TextArea,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const name = ref("");
|
||||
const bio = ref("");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full max-w-64 flex-col gap-4">
|
||||
<TextField v-model="name" name="name">
|
||||
<Label>显示名称</Label>
|
||||
<Input placeholder="Jane" />
|
||||
<Description>字符数: {{ name.length }}</Description>
|
||||
</TextField>
|
||||
<TextField v-model="bio" name="bio">
|
||||
<Label>个人简介</Label>
|
||||
<TextArea placeholder="介绍一下你自己…" />
|
||||
<Description>字符数: {{ bio.length }} / 200</Description>
|
||||
</TextField>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { Description, Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField
|
||||
class="w-full max-w-64"
|
||||
default-value="USR-12345"
|
||||
is-disabled
|
||||
name="accountId"
|
||||
>
|
||||
<Label>账户 ID</Label>
|
||||
<Input placeholder="自动生成" />
|
||||
<Description>此字段不可编辑</Description>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { FieldError, Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-[400px] space-y-4">
|
||||
<TextField full-width name="name">
|
||||
<Label>你的姓名</Label>
|
||||
<Input placeholder="John" />
|
||||
</TextField>
|
||||
<TextField
|
||||
full-width
|
||||
is-invalid
|
||||
is-required
|
||||
name="password"
|
||||
type="password"
|
||||
>
|
||||
<Label>密码</Label>
|
||||
<Input />
|
||||
<FieldError>密码长度必须超过 8 个字符</FieldError>
|
||||
</TextField>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full max-w-64 flex-col gap-4">
|
||||
<TextField name="password" type="password">
|
||||
<Label>密码</Label>
|
||||
<Input placeholder="••••••••" />
|
||||
</TextField>
|
||||
|
||||
<TextField name="age" type="number">
|
||||
<Label>年龄</Label>
|
||||
<Input max="150" min="0" placeholder="21" />
|
||||
</TextField>
|
||||
|
||||
<TextField name="email" type="email">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="user@example.com" />
|
||||
</TextField>
|
||||
|
||||
<TextField name="website" type="url">
|
||||
<Label>网站</Label>
|
||||
<Input placeholder="https://example.com" />
|
||||
</TextField>
|
||||
|
||||
<TextField name="phone" type="tel">
|
||||
<Label>电话</Label>
|
||||
<Input placeholder="+1 (555) 000-0000" />
|
||||
</TextField>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Description,
|
||||
Input,
|
||||
Label,
|
||||
Surface,
|
||||
TextArea,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Surface class="flex w-full min-w-[340px] flex-col gap-4 rounded-3xl p-6">
|
||||
<TextField name="name" variant="secondary">
|
||||
<Label>你的姓名</Label>
|
||||
<Input class="w-full" placeholder="John" />
|
||||
<Description>我们绝不会与他人分享此信息</Description>
|
||||
</TextField>
|
||||
<TextField name="email" type="email" variant="secondary">
|
||||
<Label>邮箱</Label>
|
||||
<Input class="w-full" placeholder="john@example.com" />
|
||||
</TextField>
|
||||
<TextField name="bio" variant="secondary">
|
||||
<Label>个人简介</Label>
|
||||
<TextArea class="w-full" placeholder="介绍一下你自己…" :rows="4" />
|
||||
<Description>至少 4 行</Description>
|
||||
</TextField>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 上游 render 自定义根节点;Vue 将 data-* 透传到 TextField 根,不支持替换元素类型。 -->
|
||||
<TextField
|
||||
class="w-full max-w-64"
|
||||
data-custom="foo"
|
||||
name="email"
|
||||
type="email"
|
||||
>
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="输入你的邮箱" />
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { Description, Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField class="w-full max-w-64" is-required name="fullName">
|
||||
<Label>全名</Label>
|
||||
<Input placeholder="John Doe" />
|
||||
<Description>此字段为必填项</Description>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Description,
|
||||
Label,
|
||||
TextArea,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField class="w-full max-w-64" name="message">
|
||||
<Label>消息</Label>
|
||||
<TextArea placeholder="在此输入你的消息…" :rows="4" />
|
||||
<Description>最多 500 个字符</Description>
|
||||
</TextField>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { FieldError, Input, Label, TextField } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField class="w-full max-w-64" is-invalid name="email" type="email">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="user@example.com" />
|
||||
<FieldError>请输入有效的邮箱地址</FieldError>
|
||||
</TextField>
|
||||
</template>
|
||||
Reference in New Issue
Block a user