feat: initialize Vue component library and aligned documentation

This commit is contained in:
maoyingjie
2026-10-21 09:06:28 +08:00
commit 9d40dc0ecb
149 changed files with 13208 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@heroui-vue/components";
const pressed = ref(false);
</script>
<template>
<Button @click="pressed = true">{{ pressed ? "按钮已按下" : "点我" }}</Button>
</template>
+35
View File
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { Button } from "@heroui-vue/components";
</script>
<template>
<Button
variant="ghost"
class="gradient-border relative z-0 rounded-full bg-linear-to-t from-neutral-100 to-white px-10 py-3 font-[450] text-neutral-800 shadow-none transition-all duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] [--gradient-border-width:1.5px] [--gradient-border:linear-gradient(315deg,#e5e5e5_0%,#fafafa_50%,#c4c4c4_100%)] hover:from-white hover:to-neutral-50 hover:brightness-105 active:scale-95 dark:from-neutral-900 dark:via-neutral-800 dark:to-neutral-800/80 dark:text-neutral-100 dark:[--gradient-border:linear-gradient(315deg,#404040_0%,#262626_50%,#525252_100%)] dark:hover:from-neutral-800 dark:hover:via-neutral-800 dark:hover:to-neutral-900/90 motion-reduce:transition-none"
:style="{
boxShadow:
'rgba(0, 0, 0, 0.02) 0px 1px 6px, rgba(0, 0, 0, 0.02) 0px 3px 12px, rgba(0, 0, 0, 0.01) 0px 8px 24px, rgba(0, 0, 0, 0.02) 0px 18px 40px, rgba(0, 0, 0, 0.02) 0px 40px 80px',
}"
>
升级
</Button>
</template>
<style scoped>
.gradient-border::before {
content: "";
position: absolute;
inset: 0;
z-index: 0;
border-radius: inherit;
padding: var(--gradient-border-width, 1px);
background: var(--gradient-border);
pointer-events: none;
-webkit-mask:
linear-gradient(#fff 0 0) content-box,
linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
mask:
linear-gradient(#fff 0 0) content-box,
linear-gradient(#fff 0 0);
mask-composite: exclude;
}
</style>
@@ -0,0 +1,58 @@
<script setup lang="ts">
import { defineComponent, h, type PropType } from "vue";
import { Button, buttonVariants, tv } from "@heroui-vue/components";
const myButtonVariants = tv({
extend: buttonVariants,
base: "text-base font-semibold shadow-md text-shadow-lg data-[pending=true]:opacity-40",
variants: {
variant: {
primary:
"text-white dark:bg-white/10 dark:text-white dark:hover:bg-white/15",
},
radius: {
full: "rounded-full",
lg: "rounded-lg",
md: "rounded-md",
sm: "rounded-sm",
},
size: {
sm: "h-10 px-4",
md: "h-11 px-6",
lg: "h-12 px-8",
xl: "h-13 px-10",
},
},
defaultVariants: { radius: "full", size: "md", variant: "primary" },
});
const CustomButton = defineComponent({
inheritAttrs: false,
props: {
radius: {
type: String as PropType<"full" | "lg" | "md" | "sm">,
default: "full",
},
size: {
type: String as PropType<"sm" | "md" | "lg" | "xl">,
default: "md",
},
},
setup(props, { attrs, slots }) {
return () =>
h(
Button,
{
...attrs,
class: myButtonVariants({
radius: props.radius,
size: props.size,
class: attrs.class as string,
}),
},
slots,
);
},
});
</script>
<template>
<CustomButton>自定义按钮</CustomButton>
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="demo-row">
<Button is-disabled variant="primary">主要</Button>
<Button is-disabled variant="secondary">次要</Button>
<Button is-disabled variant="tertiary">第三</Button>
<Button is-disabled variant="outline">线框</Button>
<Button is-disabled variant="ghost">幽灵</Button>
<Button is-disabled variant="danger">危险</Button>
</div>
</template>
+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { IconPlus } from "@tabler/icons-vue";
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="full-width-demo">
<Button full-width>主要按钮</Button>
<Button full-width>
<IconPlus aria-hidden="true" />
带图标
</Button>
</div>
</template>
<style scoped>
.full-width-demo {
display: flex;
flex-direction: column;
gap: 12px;
width: 400px;
max-width: 100%;
}
</style>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { IconDots, IconSettings, IconTrash } from "@tabler/icons-vue";
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="demo-row">
<Button is-icon-only variant="tertiary" aria-label="更多选项">
<IconDots aria-hidden="true" />
</Button>
<Button is-icon-only variant="secondary" aria-label="设置">
<IconSettings aria-hidden="true" />
</Button>
<Button is-icon-only variant="danger" aria-label="删除">
<IconTrash aria-hidden="true" />
</Button>
</div>
</template>
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { IconLoader2 } from "@tabler/icons-vue";
import { IconPaperclip } from "@tabler/icons-vue";
import { ref, onBeforeUnmount } from "vue";
import { Button } from "@heroui-vue/components";
const isLoading = ref(false),
message = ref("");
let timer: ReturnType<typeof setTimeout> | undefined;
function upload() {
if (isLoading.value) return;
isLoading.value = true;
message.value = "";
timer = setTimeout(() => {
isLoading.value = false;
message.value = "上传完成,可以再次上传。";
}, 2000);
}
onBeforeUnmount(() => clearTimeout(timer));
</script>
<template>
<div class="upload-demo">
<Button :is-pending="isLoading" @click="upload">
<span
v-if="isLoading"
data-slot="spinner"
class="inline-flex size-4 shrink-0"
aria-hidden="true"
>
<IconLoader2
class="size-full animate-spin motion-reduce:animate-none"
/>
</span>
<IconPaperclip v-else aria-hidden="true" />
{{ isLoading ? "上传中…" : "上传文件" }}
</Button>
<p class="upload-status" role="status">{{ message }}</p>
</div>
</template>
<style scoped>
.upload-demo {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.upload-status {
font-size: 12px;
color: var(--muted);
min-height: 20px;
margin: 0;
}
</style>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { IconLoader2 } from "@tabler/icons-vue";
import { Button } from "@heroui-vue/components";
</script>
<template>
<Button is-pending v-slot="{ isPending }">
<span
v-if="isPending"
data-slot="spinner"
class="inline-flex size-4 shrink-0"
aria-hidden="true"
>
<IconLoader2 class="size-full animate-spin motion-reduce:animate-none" />
</span>
上传中…
</Button>
</template>
@@ -0,0 +1,8 @@
<script setup lang="ts">
import { Button } from "@heroui-vue/components";
</script>
<template>
<Button as-child v-slot="{ isPressed }">
<button :data-custom="isPressed ? 'pressed' : 'bar'">点按</button>
</Button>
</template>
+74
View File
@@ -0,0 +1,74 @@
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@heroui-vue/components";
const waves = ref<{ id: number; x: number; y: number; size: number }[]>([]);
let id = 0;
function add(target: HTMLElement, x: number, y: number) {
const size = Math.max(target.offsetWidth, target.offsetHeight) * 2;
waves.value.push({ id: ++id, x: x - size / 2, y: y - size / 2, size });
}
function ripple(event: PointerEvent) {
const target = event.currentTarget as HTMLElement;
const rect = target.getBoundingClientRect();
add(target, event.clientX - rect.left, event.clientY - rect.top);
}
function keyboardRipple(event: KeyboardEvent) {
if (event.repeat || !["Enter", " "].includes(event.key)) return;
const target = event.currentTarget as HTMLElement;
add(target, target.offsetWidth / 2, target.offsetHeight / 2);
}
function remove(id: number) {
waves.value = waves.value.filter((wave) => wave.id !== id);
}
</script>
<template>
<Button
variant="secondary"
class="ripple-button"
@pointerdown="ripple"
@keydown="keyboardRipple"
>
点我
<span
v-for="wave in waves"
:key="wave.id"
class="ripple-wave"
:style="{
left: wave.x + 'px',
top: wave.y + 'px',
width: wave.size + 'px',
height: wave.size + 'px',
}"
aria-hidden="true"
@animationend="remove(wave.id)"
/>
</Button>
</template>
<style scoped>
.ripple-button {
overflow: hidden;
}
.ripple-wave {
position: absolute;
pointer-events: none;
border-radius: 50%;
background: currentColor;
opacity: 0.18;
transform: scale(0);
animation: button-ripple 0.6s ease-out forwards;
}
@keyframes button-ripple {
to {
transform: scale(1);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.ripple-wave {
animation-duration: 1ms;
}
}
:global([data-reduce-motion="true"]) .ripple-wave {
animation-duration: 1ms;
}
</style>
+10
View File
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="demo-row">
<Button size="sm">小</Button>
<Button size="md">中</Button>
<Button size="lg">大</Button>
</div>
</template>
+33
View File
@@ -0,0 +1,33 @@
<script setup lang="ts">
import {
IconBrandGoogle,
IconBrandGithubFilled,
IconBrandAppleFilled,
} from "@tabler/icons-vue";
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="social-demo">
<Button full-width variant="tertiary">
<IconBrandGoogle aria-hidden="true" />
使用 Google 登录
</Button>
<Button full-width variant="tertiary">
<IconBrandGithubFilled aria-hidden="true" />
使用 GitHub 登录
</Button>
<Button full-width variant="tertiary">
<IconBrandAppleFilled aria-hidden="true" />
使用 Apple 登录
</Button>
</div>
</template>
<style scoped>
.social-demo {
display: flex;
flex-direction: column;
gap: 12px;
width: 320px;
max-width: 100%;
}
</style>
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="demo-row">
<Button variant="primary">主要</Button>
<Button variant="secondary">次要</Button>
<Button variant="tertiary">第三</Button>
<Button variant="outline">线框</Button>
<Button variant="ghost">幽灵</Button>
<Button variant="danger">危险</Button>
<Button variant="danger-soft">柔和危险</Button>
</div>
</template>
+29
View File
@@ -0,0 +1,29 @@
<script setup lang="ts">
import {
IconSearch,
IconUserPlus,
IconMail,
IconTrash,
} from "@tabler/icons-vue";
import { Button } from "@heroui-vue/components";
</script>
<template>
<div class="demo-row">
<Button variant="primary">
<IconSearch aria-hidden="true" />
搜索
</Button>
<Button variant="secondary">
<IconUserPlus aria-hidden="true" />
添加成员
</Button>
<Button variant="tertiary">
<IconMail aria-hidden="true" />
邮件
</Button>
<Button variant="danger">
<IconTrash aria-hidden="true" />
删除
</Button>
</div>
</template>
+70
View File
@@ -0,0 +1,70 @@
<script setup lang="ts">
import { IconStar, IconCheck } from "@tabler/icons-vue";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
Button,
} from "@heroui-vue/components";
const features = [
"无限项目与协作者",
"优先支持,24 小时响应",
"高级分析与导出",
];
</script>
<template>
<Card
class="relative w-full max-w-md overflow-hidden border border-accent/20 bg-linear-to-br from-accent/12 via-surface to-surface-secondary shadow-lg shadow-accent/10 dark:border-accent/30 dark:from-accent/20 dark:via-surface dark:to-accent/8 dark:shadow-accent/5"
>
<div
aria-hidden="true"
class="pointer-events-none absolute -top-12 -right-12 size-40 rounded-full bg-accent/20 blur-3xl dark:bg-accent/30"
/>
<div
aria-hidden="true"
class="pointer-events-none absolute -bottom-8 -left-8 size-28 rounded-full bg-accent/10 blur-2xl dark:bg-accent/20"
/>
<CardHeader class="relative gap-3">
<span
class="w-fit rounded-full bg-accent/15 px-2.5 py-0.5 text-xs font-medium tracking-wide text-accent dark:bg-accent/25 dark:text-accent-soft-foreground"
>
推荐
</span>
<div class="flex items-start gap-3">
<div
class="flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent/15 text-accent dark:bg-accent/20 dark:text-accent-soft-foreground"
>
<IconStar aria-hidden="true" class="size-5" />
</div>
<div class="flex flex-col gap-1">
<CardTitle>升级到 Pro</CardTitle>
<CardDescription>
解锁面向成长型产品的团队工作流与洞察。
</CardDescription>
</div>
</div>
</CardHeader>
<CardContent class="relative">
<ul class="flex flex-col gap-2">
<li
v-for="feature in features"
:key="feature"
class="flex items-center gap-2 text-sm text-muted"
>
<IconCheck aria-hidden="true" class="size-4 shrink-0 text-accent" />
{{ feature }}
</li>
</ul>
</CardContent>
<CardFooter class="relative flex-col gap-2 sm:flex-row">
<Button class="w-full shadow-md shadow-accent/20">立即升级</Button>
<Button class="w-full" variant="secondary">对比方案</Button>
</CardFooter>
</Card>
</template>
+34
View File
@@ -0,0 +1,34 @@
<script setup lang="ts">
import { IconArrowUpRight } from "@tabler/icons-vue";
import { IconCoin } from "@tabler/icons-vue";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardFooter,
} from "@heroui-vue/components";
</script>
<template>
<Card class="w-[400px]">
<IconCoin role="img" aria-label="美元图标" class="size-6" />
<CardHeader>
<CardTitle>成为 Acme 创作者!</CardTitle>
<CardDescription>
前往 Acme 创作者中心立即注册,开始从粉丝与支持者处获得积分奖励。
</CardDescription>
</CardHeader>
<CardFooter>
<a
class="demo-link inline-flex items-center gap-1"
aria-label="前往 Acme 创作者中心(在新标签页打开)"
href="https://heroui.com"
rel="noopener noreferrer"
target="_blank"
>
创作者中心
<IconArrowUpRight aria-hidden="true" class="size-3" />
</a>
</CardFooter>
</Card>
</template>
+53
View File
@@ -0,0 +1,53 @@
<script setup lang="ts">
import { closeButtonVariants } from "@heroui-vue/styles";
import { IconX } from "@tabler/icons-vue";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardFooter,
Button,
} from "@heroui-vue/components";
</script>
<template>
<Card class="w-full items-stretch md:flex-row">
<div
class="relative h-[140px] w-full shrink-0 overflow-hidden rounded-2xl sm:h-[120px] sm:w-[120px]"
>
<img
alt="樱桃"
class="pointer-events-none absolute inset-0 h-full w-full scale-125 object-cover select-none"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/cherries.jpeg"
/>
</div>
<div class="flex flex-1 flex-col gap-3">
<CardHeader class="gap-1">
<CardTitle class="pe-8">成为 ACME 创作者!</CardTitle>
<CardDescription>
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
</CardDescription>
<button
type="button"
:class="closeButtonVariants()"
aria-label="关闭横幅"
class="absolute end-3 top-3"
>
<IconX aria-hidden="true" />
</button>
</CardHeader>
<CardFooter
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
>
<div class="flex flex-col">
<span class="text-sm font-medium text-foreground">
仅剩 10 个名额
</span>
<span class="text-xs text-muted">报名截止:10 月 10 日</span>
</div>
<Button class="w-full sm:w-auto">立即申请</Button>
</CardFooter>
</div>
</Card>
</template>
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
} from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-col gap-4">
<Card class="w-[320px]" variant="transparent">
<CardHeader>
<CardTitle>透明</CardTitle>
<CardDescription>背景透明,视觉层级较低(transparent)</CardDescription>
</CardHeader>
<CardContent>
<p>适合次要内容或嵌套在其它容器中的卡片</p>
</CardContent>
</Card>
<Card class="w-[320px]" variant="default">
<CardHeader>
<CardTitle>默认</CardTitle>
<CardDescription>标准外观(bg-surface)</CardDescription>
</CardHeader>
<CardContent>
<p>大多数场景的默认卡片变体</p>
</CardContent>
</Card>
<Card class="w-[320px]" variant="secondary">
<CardHeader>
<CardTitle>次要</CardTitle>
<CardDescription>中等强调(bg-surface-secondary)</CardDescription>
</CardHeader>
<CardContent>
<p>用于需要适度吸引注意力的内容</p>
</CardContent>
</Card>
<Card class="w-[320px]" variant="tertiary">
<CardHeader>
<CardTitle>第三</CardTitle>
<CardDescription>更高强调(bg-surface-tertiary)</CardDescription>
</CardHeader>
<CardContent>
<p>适合主要内容或需要突出的展示位</p>
</CardContent>
</Card>
</div>
</template>
+75
View File
@@ -0,0 +1,75 @@
<script setup lang="ts">
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardFooter,
} from "@heroui-vue/components";
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
</script>
<template>
<div class="flex flex-wrap gap-4">
<Card class="w-[200px] gap-2">
<img
alt="独立创客社区"
class="pointer-events-none aspect-square w-14 rounded-2xl object-cover select-none"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo1.jpg"
/>
<CardHeader>
<CardTitle>Indie Hackers</CardTitle>
<CardDescription>148 位成员</CardDescription>
</CardHeader>
<CardFooter class="flex gap-2">
<AvatarRoot
aria-label="玛莎的头像"
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
>
<AvatarImage
class="size-full object-cover"
alt="玛莎的头像"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default text-xs"
>
IH
</AvatarFallback>
</AvatarRoot>
<span class="text-xs">创建者:玛莎</span>
</CardFooter>
</Card>
<Card class="w-[200px] gap-2">
<img
alt="AI 开发者社区"
class="pointer-events-none aspect-square w-14 rounded-2xl object-cover select-none"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo2.jpg"
/>
<CardHeader>
<CardTitle>AI Builders</CardTitle>
<CardDescription>362 位成员</CardDescription>
</CardHeader>
<CardFooter class="flex gap-2">
<AvatarRoot
aria-label="约翰的头像"
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
>
<AvatarImage
class="size-full object-cover"
alt="约翰的头像"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default text-xs"
>
B
</AvatarFallback>
</AvatarRoot>
<span class="text-xs">创建者:约翰</span>
</CardFooter>
</Card>
</div>
</template>
+71
View File
@@ -0,0 +1,71 @@
<script setup lang="ts">
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
Button,
} from "@heroui-vue/components";
import { Input, Label } from "@heroui-vue/components";
import { ref, useId } from "vue";
const id = useId();
const submitted = ref(false);
const message = ref("");
</script>
<template>
<Card class="w-full max-w-md">
<CardHeader>
<CardTitle>登录</CardTitle>
<CardDescription>输入账号信息以访问您的账户</CardDescription>
</CardHeader>
<form class="flex flex-col" @submit.prevent="submitted = true">
<CardContent>
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-1">
<Label :for="id + '-email'">邮箱</Label>
<Input
:id="id + '-email'"
name="email"
type="email"
autocomplete="email"
placeholder="email@example.com"
variant="secondary"
required
/>
</div>
<div class="flex flex-col gap-1">
<Label :for="id + '-password'">密码</Label>
<Input
:id="id + '-password'"
name="password"
type="password"
autocomplete="current-password"
placeholder="••••••••"
variant="secondary"
required
/>
</div>
</div>
</CardContent>
<CardFooter class="mt-4 flex flex-col gap-2">
<Button class="w-full" type="submit">登录</Button>
<a
class="demo-link text-center text-sm"
href="#"
@click.prevent="message = '请联系账户管理员重置密码。'"
>
忘记密码?
</a>
</CardFooter>
<p
v-if="submitted || message"
role="status"
class="mt-2 text-sm text-muted"
>
{{ message || "表单提交成功!此示例不会发送账号信息。" }}
</p>
</form>
</Card>
</template>
+289
View File
@@ -0,0 +1,289 @@
<script setup lang="ts">
import { closeButtonVariants } from "@heroui-vue/styles";
import { IconArrowUpRight, IconX } from "@tabler/icons-vue";
import { IconCoin } from "@tabler/icons-vue";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
Button,
} from "@heroui-vue/components";
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
</script>
<template>
<div class="flex w-full items-center justify-center">
<div class="grid w-full max-w-2xl grid-cols-12 gap-4 p-4">
<Card class="col-span-12 flex h-auto min-h-[152px] flex-col sm:flex-row">
<div
class="relative h-[140px] w-full shrink-0 overflow-hidden rounded-2xl sm:h-[120px] sm:w-[120px]"
>
<img
alt="樱桃"
class="pointer-events-none absolute inset-0 h-full w-full scale-125 object-cover select-none"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/cherries.jpeg"
/>
</div>
<div class="flex flex-1 flex-col gap-3">
<CardHeader class="gap-1">
<CardTitle class="pe-8">成为 ACME 创作者!</CardTitle>
<CardDescription>
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
</CardDescription>
<button
type="button"
:class="closeButtonVariants()"
aria-label="关闭横幅"
class="absolute end-3 top-3"
>
<IconX aria-hidden="true" />
</button>
</CardHeader>
<CardFooter
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
>
<div class="flex flex-col">
<span class="text-sm font-medium text-foreground">
仅剩 10 个名额
</span>
<span class="text-xs text-muted">报名截止:10 月 10 日</span>
</div>
<Button class="w-full sm:w-auto">立即申请</Button>
</CardFooter>
</div>
</Card>
<div class="col-span-12 grid grid-cols-12 gap-4">
<div class="col-span-12 grid grid-cols-12 gap-4 lg:col-span-6">
<Card class="col-span-12">
<div class="absolute end-3 top-3 z-10">
<button
type="button"
:class="closeButtonVariants()"
aria-label="关闭通知"
>
<IconX aria-hidden="true" />
</button>
</div>
<CardHeader class="gap-3">
<IconCoin
role="img"
aria-label="美元图标"
class="size-8 shrink-0"
/>
<div class="flex flex-col gap-1">
<span class="text-xs font-medium text-muted uppercase">
支付
</span>
<CardTitle class="pe-8 text-sm sm:text-base">
现已支持加密货币提现
</CardTitle>
<CardDescription class="text-xs sm:text-sm">
在设置中添加钱包即可提现
</CardDescription>
</div>
</CardHeader>
<CardFooter>
<a
class="demo-link inline-flex items-center gap-1"
aria-label="前往设置"
href="#"
rel="noopener noreferrer"
>
前往设置
<IconArrowUpRight aria-hidden="true" class="size-3" />
</a>
</CardFooter>
</Card>
<div class="col-span-12 grid grid-cols-12 gap-4">
<Card class="col-span-12 gap-2 sm:col-span-6">
<CardHeader>
<AvatarRoot
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
>
<AvatarImage
class="size-full object-cover"
alt="演示图片 1"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo1.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default"
>
JK
</AvatarFallback>
</AvatarRoot>
</CardHeader>
<CardContent class="mt-1">
<p class="text-sm leading-4 font-medium">Indie Hackers</p>
<p class="text-xs text-muted">148 位成员</p>
</CardContent>
<CardFooter class="flex items-center gap-2">
<AvatarRoot
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
>
<AvatarImage
class="size-full object-cover"
alt="约翰"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default"
>
JK
</AvatarFallback>
</AvatarRoot>
<p class="text-xs text-muted">创建者:约翰</p>
</CardFooter>
</Card>
<Card class="col-span-12 gap-2 sm:col-span-6">
<CardHeader>
<AvatarRoot
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
>
<AvatarImage
class="size-full object-cover"
alt="演示图片 2"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo2.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default"
>
AB
</AvatarFallback>
</AvatarRoot>
</CardHeader>
<CardContent class="mt-1">
<p class="text-sm leading-4 font-medium">AI Builders</p>
<p class="text-xs text-muted">362 位成员</p>
</CardContent>
<CardFooter class="flex items-center gap-2">
<AvatarRoot
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
>
<AvatarImage
class="size-full object-cover"
alt="玛莎"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
/>
<AvatarFallback
class="flex size-full items-center justify-center bg-default"
>
M
</AvatarFallback>
</AvatarRoot>
<p class="text-xs text-muted">创建者:玛莎</p>
</CardFooter>
</Card>
</div>
</div>
<Card
class="col-span-12 min-h-[200px] overflow-hidden rounded-3xl lg:col-span-6"
>
<img
alt="NEO 家用机器人"
aria-hidden="true"
class="absolute inset-0 h-full w-full object-cover"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/neo2.jpeg"
/>
<CardHeader class="z-10 text-white">
<CardTitle
class="text-xs font-semibold tracking-wide text-black/70"
>
NEO
</CardTitle>
<CardDescription
class="text-sm leading-5 font-medium text-black/50"
>
家用机器人
</CardDescription>
</CardHeader>
<CardFooter class="z-10 mt-auto flex items-center justify-between">
<div>
<div class="text-sm font-medium text-black">即将推出</div>
<div class="text-xs text-black/60">接收上架通知</div>
</div>
<Button class="bg-white text-black" size="sm" variant="tertiary">
通知我
</Button>
</CardFooter>
</Card>
</div>
<div class="col-span-12 grid grid-cols-12 gap-4">
<Card
class="relative col-span-12 h-[250px] sm:h-[300px] md:col-span-8 md:h-[350px]"
>
<img
alt="NEO 家用机器人"
aria-hidden="true"
class="absolute inset-0 h-full w-full object-cover"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/neo1.jpeg"
/>
<CardFooter class="z-10 mt-auto flex items-end justify-between">
<div>
<div class="text-base font-medium text-black sm:text-lg">NEO</div>
<div class="text-xs font-medium text-black/50 sm:text-sm">
$499/月
</div>
</div>
<Button class="bg-white text-black" size="sm" variant="tertiary">
立即购买
</Button>
</CardFooter>
</Card>
<div
class="col-span-12 flex flex-col gap-2 md:col-span-4 md:justify-between md:gap-0 md:py-2"
>
<Card class="flex flex-row gap-3 p-1" variant="transparent">
<img
alt="未来感机器人"
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/robot1.jpeg"
/>
<div class="flex flex-1 flex-col justify-center gap-1">
<CardTitle class="text-sm">连接未来</CardTitle>
<CardDescription class="text-xs">今天 18:30</CardDescription>
</div>
</Card>
<Card class="flex flex-row gap-3 p-1" variant="transparent">
<img
alt="牛油果"
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/avocado.jpeg"
/>
<div class="flex flex-1 flex-col justify-center gap-1">
<CardTitle class="text-sm">牛油果黑客松</CardTitle>
<CardDescription class="text-xs">周三 16:30</CardDescription>
</div>
</Card>
<Card class="flex flex-row gap-3 p-1" variant="transparent">
<img
alt="Sound Electro 活动"
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
loading="lazy"
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/oranges.jpeg"
/>
<div class="flex flex-1 flex-col justify-center gap-1">
<CardTitle class="text-sm">Sound Electro|超越艺术</CardTitle>
<CardDescription class="text-xs">周五 20:00</CardDescription>
</div>
</Card>
</div>
</div>
</div>
</div>
</template>
+6
View File
@@ -0,0 +1,6 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
</script>
<template>
<Input aria-label="姓名" class="w-64" placeholder="输入你的姓名" />
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
import { ref } from "vue";
const value = ref("heroui.com");
</script>
<template>
<div class="flex w-80 flex-col gap-2">
<Input v-model="value" aria-label="域名" placeholder="域名" />
<span class="px-1 text-sm text-muted">
https://{{ value || "你的域名" }}
</span>
</div>
</template>
+10
View File
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
</script>
<template>
<Input
aria-label="搜索项目"
class="w-64 rounded-xl border border-border/80 bg-default text-foreground placeholder:text-muted"
placeholder="搜索项目…"
/>
</template>
+8
View File
@@ -0,0 +1,8 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
</script>
<template>
<div class="w-[400px] space-y-3">
<Input full-width aria-label="全宽输入框" placeholder="全宽输入框" />
</div>
</template>
+15
View File
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
</script>
<template>
<div
class="flex h-[180px] w-[280px] items-center justify-center rounded-3xl bg-surface p-4"
>
<Input
class="w-full"
aria-label="你的姓名"
placeholder="你的姓名"
variant="secondary"
/>
</div>
</template>
+21
View File
@@ -0,0 +1,21 @@
<script setup lang="ts">
import { Input, Label } from "@heroui-vue/components";
import { useId } from "vue";
const id = useId();
</script>
<template>
<div class="flex w-80 flex-col gap-4">
<div class="flex flex-col gap-1">
<Label :for="id + '-email'">邮箱</Label>
<Input :id="id + '-email'" placeholder="jane@example.com" type="email" />
</div>
<div class="flex flex-col gap-1">
<Label :for="id + '-number'">年龄</Label>
<Input :id="id + '-number'" :min="0" placeholder="30" type="number" />
</div>
<div class="flex flex-col gap-1">
<Label :for="id + '-password'">密码</Label>
<Input :id="id + '-password'" placeholder="••••••••" type="password" />
</div>
</div>
</template>
+19
View File
@@ -0,0 +1,19 @@
<script setup lang="ts">
import { Input } from "@heroui-vue/components";
</script>
<template>
<div class="flex w-[240px] flex-col gap-2">
<Input
full-width
aria-label="主要输入框"
placeholder="主要输入框"
variant="primary"
/>
<Input
full-width
aria-label="次要输入框"
placeholder="次要输入框"
variant="secondary"
/>
</div>
</template>
+18
View File
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch>
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
启用通知
</SwitchContent>
</Switch>
</template>
+21
View File
@@ -0,0 +1,21 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
import { ref } from "vue";
const selected = ref(false);
</script>
<template>
<div class="flex flex-col gap-4">
<Switch v-model:checked="selected">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
启用通知
</SwitchContent>
</Switch>
<p class="text-sm text-muted">开关{{ selected ? "已打开" : "已关闭" }}</p>
</div>
</template>
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
Label,
Description,
} from "@heroui-vue/components";
</script>
<template>
<Switch>
<SwitchContent>
<SwitchControl
class="[--switch-control-bg-checked-hover:var(--success)] [--switch-control-bg-checked:var(--success)]"
>
<SwitchThumb />
</SwitchControl>
<div class="flex flex-col gap-0.5">
<Label>自动保存草稿</Label>
<Description>输入时会自动保存更改。</Description>
</div>
</SwitchContent>
</Switch>
</template>
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch default-selected>
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
启用通知
</SwitchContent>
</Switch>
</template>
+18
View File
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch is-disabled>
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
启用通知
</SwitchContent>
</Switch>
</template>
+57
View File
@@ -0,0 +1,57 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
SwitchGroup,
Button,
} from "@heroui-vue/components";
import { ref } from "vue";
const result = ref("");
function submit(event: Event) {
const values = [...new FormData(event.target as HTMLFormElement).entries()];
result.value = values.length
? "表单提交内容:" + values.map(([k, v]) => `${k}: ${v}`).join(",")
: "未选择任何选项";
}
</script>
<template>
<form class="flex flex-col gap-4" @submit.prevent="submit">
<SwitchGroup>
<Switch name="notifications" value="on">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
启用通知
</SwitchContent>
</Switch>
<Switch default-selected name="newsletter" value="on">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
订阅新闻简报
</SwitchContent>
</Switch>
<Switch name="marketing" value="on">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
接收营销更新
</SwitchContent>
</Switch>
</SwitchGroup>
<div class="flex gap-2">
<Button class="mt-4" size="sm" type="submit">Submit</Button>
<Button
class="mt-4"
size="sm"
type="reset"
variant="secondary"
@click="result = ''"
>
重置
</Button>
</div>
<output v-if="result" class="text-sm text-muted" aria-live="polite">
{{ result }}
</output>
</form>
</template>
@@ -0,0 +1,37 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
SwitchGroup,
} from "@heroui-vue/components";
</script>
<template>
<SwitchGroup class="overflow-x-auto" orientation="horizontal">
<Switch name="notifications">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
通知
</SwitchContent>
</Switch>
<Switch name="marketing">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
营销
</SwitchContent>
</Switch>
<Switch name="social">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
社交
</SwitchContent>
</Switch>
</SwitchGroup>
</template>
+37
View File
@@ -0,0 +1,37 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
SwitchGroup,
} from "@heroui-vue/components";
</script>
<template>
<SwitchGroup>
<Switch name="notifications">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
允许通知
</SwitchContent>
</Switch>
<Switch name="marketing">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
营销邮件
</SwitchContent>
</Switch>
<Switch name="social">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
社交媒体更新
</SwitchContent>
</Switch>
</SwitchGroup>
</template>
+28
View File
@@ -0,0 +1,28 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-col gap-4">
<Switch>
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
标签在后
</SwitchContent>
</Switch>
<Switch>
<SwitchContent>
标签在前
<SwitchControl>
<SwitchThumb />
</SwitchControl>
</SwitchContent>
</Switch>
</div>
</template>
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch as-child>
<div data-custom="foo">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
启用通知
</SwitchContent>
</div>
</Switch>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch v-slot="{ isSelected }">
<SwitchContent>
<SwitchControl><SwitchThumb /></SwitchControl>
{{ isSelected ? "已开启" : "已关闭" }}
</SwitchContent>
</Switch>
</template>
+36
View File
@@ -0,0 +1,36 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<div class="flex gap-6">
<Switch size="sm">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
小
</SwitchContent>
</Switch>
<Switch size="md">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
中
</SwitchContent>
</Switch>
<Switch size="lg">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
大
</SwitchContent>
</Switch>
</div>
</template>
@@ -0,0 +1,22 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
Description,
} from "@heroui-vue/components";
</script>
<template>
<div class="max-w-sm">
<Switch>
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
公开资料
</SwitchContent>
<Description>允许他人查看你的资料信息</Description>
</Switch>
</div>
</template>
+79
View File
@@ -0,0 +1,79 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
SwitchIcon,
} from "@heroui-vue/components";
import {
IconCheck,
IconPower,
IconSun,
IconMoon,
IconMicrophone,
IconMicrophoneOff,
IconBellFilled,
IconBellOff,
IconVolume,
IconVolumeOff,
} from "@tabler/icons-vue";
const icons = [
{
key: "check",
label: "电源",
color: "bg-green-500/80",
on: IconCheck,
off: IconPower,
},
{ key: "darkMode", label: "深色模式", color: "", on: IconSun, off: IconMoon },
{
key: "microphone",
label: "静音麦克风",
color: "bg-red-500/80",
on: IconMicrophoneOff,
off: IconMicrophone,
},
{
key: "notification",
label: "通知",
color: "bg-purple-500/80",
on: IconBellFilled,
off: IconBellOff,
},
{
key: "volume",
label: "静音音量",
color: "bg-blue-500/80",
on: IconVolumeOff,
off: IconVolume,
},
];
</script>
<template>
<div class="flex flex-wrap gap-3">
<Switch
v-for="item in icons"
:key="item.key"
default-selected
size="lg"
:aria-label="item.label"
v-slot="{ isSelected }"
>
<SwitchContent>
<SwitchControl :class="isSelected ? item.color : ''">
<SwitchThumb>
<SwitchIcon>
<component
:is="isSelected ? item.on : item.off"
class="size-3 text-inherit"
:class="isSelected ? 'opacity-100' : 'opacity-70'"
aria-hidden="true"
/>
</SwitchIcon>
</SwitchThumb>
</SwitchControl>
</SwitchContent>
</Switch>
</div>
</template>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
import {
Switch,
SwitchContent,
SwitchControl,
SwitchThumb,
} from "@heroui-vue/components";
</script>
<template>
<Switch aria-label="启用通知">
<SwitchContent>
<SwitchControl>
<SwitchThumb />
</SwitchControl>
</SwitchContent>
</Switch>
</template>