feat: add Surface, Link and Spinner components
This commit is contained in:
@@ -47,6 +47,9 @@ const groups = [
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Spinner 加载指示器", url: "/components/spinner" },
|
||||
{ title: "Surface 表面", url: "/components/surface" },
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -42,9 +42,11 @@ button,
|
||||
input {
|
||||
font: inherit;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
@layer base {
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
button {
|
||||
cursor: pointer;
|
||||
|
||||
@@ -6,4 +6,7 @@ description: 已迁移组件及文档
|
||||
- [Button 按钮](./components/button)
|
||||
- [Card 卡片](./components/card)
|
||||
- [Input 输入框](./components/input)
|
||||
- [Link 链接](./components/link)
|
||||
- [Spinner 加载指示器](./components/spinner)
|
||||
- [Surface 表面](./components/surface)
|
||||
- [Switch 开关](./components/switch)
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
---
|
||||
title: Link 链接
|
||||
description: 用于导航的样式化锚点组件,内置图标支持
|
||||
component: link
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="link-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
导入 Link 与 LinkIcon 后,可按名称组合子部分。省略 LinkIcon 插槽内容时使用内置外部链接箭头图标。
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<Link href="#">
|
||||
Call to action
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 图标位置
|
||||
|
||||
<ComponentPreview name="link-icon-placement" />
|
||||
|
||||
### 配合 Tailwind CSS 的文本装饰
|
||||
|
||||
Link 默认在悬浮时显示下划线。可使用 Tailwind CSS 的 text-decoration 工具类让下划线始终可见、完全移除,或自定义其颜色、样式、粗细与偏移。
|
||||
|
||||
<ComponentPreview name="link-underline-and-offset" />
|
||||
|
||||
**文本装饰线:**
|
||||
|
||||
- `underline` — 始终显示下划线
|
||||
- `no-underline` — 移除下划线
|
||||
- 默认 `Link` 样式 — 下划线在悬浮时显示
|
||||
|
||||
**文本装饰色:**
|
||||
|
||||
- `decoration-accent`、`decoration-muted` 等 — 使用主题色设置下划线颜色
|
||||
- `decoration-muted/50` — 使用透明度修饰符实现半透明下划线
|
||||
|
||||
**文本装饰样式:**
|
||||
|
||||
- `decoration-solid` — 实线(默认)
|
||||
- `decoration-double` — 双线
|
||||
- `decoration-dotted` — 点线
|
||||
- `decoration-dashed` — 虚线
|
||||
- `decoration-wavy` — 波浪线
|
||||
|
||||
**文本装饰粗细:**
|
||||
|
||||
- `decoration-1`、`decoration-2`、`decoration-4` 等 — 控制下划线粗细
|
||||
|
||||
**下划线偏移:**
|
||||
|
||||
- `underline-offset-1`、`underline-offset-2`、`underline-offset-4` 等 — 调整文本与下划线间距
|
||||
|
||||
可用的 BEM 类:
|
||||
|
||||
- 基础:`hv-link`
|
||||
- 图标:`hv-link__icon`
|
||||
|
||||
### 自定义图标
|
||||
|
||||
<ComponentPreview name="link-custom-icon" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `asChild` 将链接属性合并到默认插槽中唯一的自定义元素,对应上游 render 函数示例,不将 render prop 原样搬入 Vue。自定义元素会获得链接角色与键盘激活(Enter 触发一次 `@click` 语义,可用 keydown `preventDefault` 取消);真实导航请使用 `a` 或路由组件。
|
||||
|
||||
<ComponentPreview name="link-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="link-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-link {
|
||||
@apply font-semibold no-underline hover:underline;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Link 使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-link` — 链接基础样式
|
||||
- `.hv-link__icon` — 链接图标样式
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件同时支持 CSS 伪类与 data 属性,以获得更大灵活性:
|
||||
|
||||
- **焦点**:`:focus-visible` 或 `[data-focus-visible="true"]`
|
||||
- **悬浮**:`:hover` 或 `[data-hovered="true"]`
|
||||
- **按下**:`:active` 或 `[data-pressed="true"]`
|
||||
- **禁用**:`:disabled` 或 `[aria-disabled="true"]`
|
||||
|
||||
## API 参考
|
||||
|
||||
### Link
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | ------------------- | --------- | -------------------------------------------------------------- |
|
||||
| `href` | `string` | - | 锚点的目标 URL |
|
||||
| `target` | `string` | `"_self"` | 在何处打开链接文档 |
|
||||
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
||||
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
||||
| `asChild` | `boolean` | `false` | 合并到默认插槽唯一元素,并补充 `role="link"` 与 `tabindex="0"` |
|
||||
| `autoFocus` | `boolean` | - | 挂载后聚焦真实 DOM 根元素(含 asChild) |
|
||||
| `class` | `string` | - | 与默认样式合并的自定义类 |
|
||||
|
||||
默认插槽渲染链接内部内容。作用域插槽提供 `isDisabled`、`isHovered`、`isPressed`、`isFocused`、`isFocusVisible`。`@click` 等 DOM 事件通过 attrs 透传;`isDisabled` 时阻止激活(含 Vue 合并后的监听器数组)。React Aria 的 `onPress` / `PressEvent` 由原生 `click` 适配,不等价。
|
||||
|
||||
`asChild` 适用于 `<a>`、`RouterLink` 等已具备导航能力的元素,以及需要自定义外观的 `span`/`div`:非原生可激活元素会获得 `role="link"`、`tabindex="0"`,Enter 触发一次激活(与点击同一 `click` 路径)。自定义元素上的 `href` 不会由浏览器直接导航,请用 `a` / 路由组件作为 asChild 目标,或在 `@click` 中自行处理跳转。禁用时仍可聚焦以便读出 `aria-disabled`,但不会激活。
|
||||
|
||||
### LinkIcon
|
||||
|
||||
| Prop | 类型 | 描述 |
|
||||
| ------- | -------- | ------------- |
|
||||
| `class` | `string` | 附加的 CSS 类 |
|
||||
|
||||
默认插槽提供自定义图标元素;省略时使用内置箭头图标,并标记 `data-default-icon`。
|
||||
|
||||
### 与路由库配合使用
|
||||
|
||||
使用变体函数为框架专用链接添加样式:
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { RouterLink } from "vue-router";
|
||||
import { linkVariants } from "@heroui-vue/styles";
|
||||
|
||||
const slots = linkVariants();
|
||||
</script>
|
||||
<template>
|
||||
<RouterLink :class="slots.base()" to="/about">
|
||||
About Page
|
||||
<span :class="slots.icon()" data-slot="link-icon" />
|
||||
</RouterLink>
|
||||
</template>
|
||||
```
|
||||
|
||||
基础包不强依赖 Vue Router;可在应用层组合 `linkVariants` 或 `.hv-link` 类。
|
||||
|
||||
### 直接应用类
|
||||
|
||||
由于 HeroUI 使用 [BEM](https://getbem.com/) 类,你可以将 Link 样式直接应用到任意链接元素:
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { RouterLink } from "vue-router";
|
||||
</script>
|
||||
<template>
|
||||
<!-- 直接使用 Tailwind 工具类 -->
|
||||
<RouterLink class="hv-link underline-offset-2" to="/about">
|
||||
About Page
|
||||
</RouterLink>
|
||||
</template>
|
||||
```
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<!-- 或使用原生 <a> -->
|
||||
<a
|
||||
href="/about"
|
||||
class="hv-link underline decoration-accent underline-offset-4"
|
||||
>
|
||||
About Page
|
||||
<span class="hv-link__icon">
|
||||
<!-- 图标内容 -->
|
||||
</span>
|
||||
</a>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Card 卡片](./card)
|
||||
@@ -0,0 +1,94 @@
|
||||
---
|
||||
title: Spinner 加载指示器
|
||||
description: 用于展示等待或处理中状态的加载指示组件
|
||||
component: spinner
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="spinner-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 颜色
|
||||
|
||||
<ComponentPreview name="spinner-colors" />
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="spinner-sizes" />
|
||||
|
||||
### 速度
|
||||
|
||||
为单个 Spinner 添加动画工具类即可调整其旋转速度。请同时加上 `motion-reduce:animate-none`,以便在用户开启“减少动态效果”时保持静止。
|
||||
|
||||
<ComponentPreview name="spinner-speed" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="spinner-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-spinner {
|
||||
@apply animate-spin;
|
||||
}
|
||||
|
||||
.hv-spinner--accent {
|
||||
color: var(--accent);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Spinner 使用以下 CSS 类:
|
||||
|
||||
#### 基础类与尺寸类 [!toc]
|
||||
|
||||
- `.hv-spinner` - 基础样式与默认尺寸
|
||||
- `.hv-spinner--sm` - 小尺寸变体
|
||||
- `.hv-spinner--md` - 中等尺寸变体(默认)
|
||||
- `.hv-spinner--lg` - 大尺寸变体
|
||||
- `.hv-spinner--xl` - 特大尺寸变体
|
||||
|
||||
#### 颜色类 [!toc]
|
||||
|
||||
- `.hv-spinner--current` - 继承当前文本颜色
|
||||
- `.hv-spinner--accent` - 强调色变体
|
||||
- `.hv-spinner--danger` - 危险色变体
|
||||
- `.hv-spinner--success` - 成功色变体
|
||||
- `.hv-spinner--warning` - 警告色变体
|
||||
|
||||
## API 参考
|
||||
|
||||
### Spinner
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------- | ------------------------------------------------------------- | ---------- | ------------------ |
|
||||
| `size` | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Spinner 的尺寸 |
|
||||
| `color` | `"current" \| "accent" \| "success" \| "warning" \| "danger"` | `"accent"` | Spinner 的颜色变体 |
|
||||
| `class` | `string` | - | 额外的 CSS 类名 |
|
||||
|
||||
根节点默认 `role="status"` 与 `aria-label="Loading"`,可通过 attrs 覆盖。内部 SVG 标记 `aria-hidden`,使用 `currentColor` 渐变;嵌入 Button 时保持所选尺寸(如 `size="sm"` 为 16px),不被 Button 的普通 SVG 规则覆盖。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Input 输入框](./input)
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
title: Surface 表面
|
||||
description: 提供表面级样式与子组件上下文的容器组件
|
||||
component: surface
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Surface } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="surface-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
Surface 提供描述 prominence 层级的语义变体:
|
||||
|
||||
- **`default`** - 标准表面外观(bg-surface)
|
||||
- **`secondary`** - 中等 prominence(bg-surface-secondary)
|
||||
- **`tertiary`** - 较高 prominence(bg-surface-tertiary)
|
||||
- **`transparent`** - 透明背景,适用于遮罩层和自定义背景
|
||||
|
||||
<ComponentPreview name="surface-variants" />
|
||||
|
||||
### 搭配表单
|
||||
|
||||
在 Surface 内使用表单组件时,请使用 `variant="secondary"` 以应用适合表面背景的低强调变体。
|
||||
|
||||
<ComponentPreview name="surface-with-form-components" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="surface-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-surface {
|
||||
@apply rounded-2xl border border-border;
|
||||
}
|
||||
|
||||
.hv-surface--secondary {
|
||||
@apply bg-gradient-to-br from-blue-50 to-purple-50;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Surface 组件使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-surface` - Surface 根容器
|
||||
|
||||
#### 变体类 [!toc]
|
||||
|
||||
- `.hv-surface--default` - 默认 Surface 变体(bg-surface)
|
||||
- `.hv-surface--secondary` - Secondary Surface 变体(bg-surface-secondary)
|
||||
- `.hv-surface--tertiary` - Tertiary Surface 变体(bg-surface-tertiary)
|
||||
- `.hv-surface--transparent` - 透明 Surface 变体
|
||||
|
||||
## API 参考
|
||||
|
||||
### Surface
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | --------------------------------------------------------- | ----------- | -------------------- |
|
||||
| `variant` | `"transparent" \| "default" \| "secondary" \| "tertiary"` | `"default"` | Surface 的视觉变体。 |
|
||||
| `class` | `string` | - | 额外的 CSS 类。 |
|
||||
|
||||
默认插槽渲染 Surface 内容。其他属性与 DOM 事件透传到根 `div`。
|
||||
|
||||
## Context API
|
||||
|
||||
### surfaceContextKey
|
||||
|
||||
子组件可通过 Surface 上下文读取当前变体:
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { inject } from "vue";
|
||||
import { surfaceContextKey } from "@heroui-vue/components";
|
||||
|
||||
const surface = inject(surfaceContextKey, undefined);
|
||||
// surface.variant.value 为 "transparent" | "default" | "secondary" | "tertiary"
|
||||
</script>
|
||||
```
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](./card) · [Input 输入框](./input) · [Button 按钮](./button)
|
||||
@@ -1,8 +1,7 @@
|
||||
<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";
|
||||
import { Button, Spinner } from "@heroui-vue/components";
|
||||
const isLoading = ref(false),
|
||||
message = ref("");
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
@@ -20,16 +19,7 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
<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>
|
||||
<Spinner v-if="isLoading" color="current" size="sm" />
|
||||
<IconPaperclip v-else aria-hidden="true" />
|
||||
{{ isLoading ? "上传中…" : "上传文件" }}
|
||||
</Button>
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { IconLoader2 } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import { Button, Spinner } 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>
|
||||
<Spinner v-if="isPending" color="current" size="sm" />
|
||||
上传中…
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { IconArrowUpRight } from "@tabler/icons-vue";
|
||||
import { IconCoin } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
@@ -7,6 +6,8 @@ import {
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
Link,
|
||||
LinkIcon,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
@@ -19,16 +20,15 @@ import {
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter>
|
||||
<a
|
||||
class="demo-link inline-flex items-center gap-1"
|
||||
<Link
|
||||
aria-label="前往 Acme 创作者中心(在新标签页打开)"
|
||||
href="https://heroui.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
创作者中心
|
||||
<IconArrowUpRight aria-hidden="true" class="size-3" />
|
||||
</a>
|
||||
<LinkIcon aria-hidden="true" />
|
||||
</Link>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
Link,
|
||||
} from "@heroui-vue/components";
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
import { ref, useId } from "vue";
|
||||
@@ -51,13 +52,13 @@ const message = ref("");
|
||||
</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"
|
||||
<Link
|
||||
class="text-center text-sm"
|
||||
href="#"
|
||||
@click.prevent="message = '请联系账户管理员重置密码。'"
|
||||
>
|
||||
忘记密码?
|
||||
</a>
|
||||
</Link>
|
||||
</CardFooter>
|
||||
<p
|
||||
v-if="submitted || message"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { closeButtonVariants } from "@heroui-vue/styles";
|
||||
import { IconArrowUpRight, IconX } from "@tabler/icons-vue";
|
||||
import { IconX } from "@tabler/icons-vue";
|
||||
import { IconCoin } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
Link,
|
||||
LinkIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</script>
|
||||
@@ -87,15 +89,10 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardFooter>
|
||||
<a
|
||||
class="demo-link inline-flex items-center gap-1"
|
||||
aria-label="前往设置"
|
||||
href="#"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Link aria-label="前往设置" href="#" rel="noopener noreferrer">
|
||||
前往设置
|
||||
<IconArrowUpRight aria-hidden="true" class="size-3" />
|
||||
</a>
|
||||
<LinkIcon aria-hidden="true" />
|
||||
</Link>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
import { Input, Surface } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex h-[180px] w-[280px] items-center justify-center rounded-3xl bg-surface p-4"
|
||||
<Surface
|
||||
class="flex h-[180px] w-[280px] items-center justify-center rounded-3xl p-4"
|
||||
variant="default"
|
||||
>
|
||||
<Input
|
||||
class="w-full"
|
||||
@@ -11,5 +12,5 @@ import { Input } from "@heroui-vue/components";
|
||||
placeholder="你的姓名"
|
||||
variant="secondary"
|
||||
/>
|
||||
</div>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Link href="#">
|
||||
立即行动
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import { IconExternalLink, IconLink } from "@tabler/icons-vue";
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Link href="#">
|
||||
外部链接
|
||||
<LinkIcon class="ms-1.5 size-3">
|
||||
<IconExternalLink aria-hidden="true" class="size-full" />
|
||||
</LinkIcon>
|
||||
</Link>
|
||||
<Link class="gap-1" href="#">
|
||||
前往页面
|
||||
<LinkIcon class="size-3">
|
||||
<IconLink aria-hidden="true" class="size-full" />
|
||||
</LinkIcon>
|
||||
</Link>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Link
|
||||
class="font-medium text-neutral-700 underline decoration-neutral-300/80 underline-offset-4 transition-colors hover:text-neutral-900 dark:text-neutral-300 dark:decoration-neutral-600/80 dark:hover:text-neutral-100"
|
||||
href="#"
|
||||
>
|
||||
立即行动
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Link href="#">
|
||||
图标在末尾(默认)
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
<Link class="gap-1" href="#">
|
||||
<LinkIcon />
|
||||
图标在开头
|
||||
</Link>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Link href="#" as-child>
|
||||
<span data-custom="foo">
|
||||
立即行动
|
||||
<LinkIcon />
|
||||
</span>
|
||||
</Link>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { Link, LinkIcon } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">默认悬浮下划线</p>
|
||||
<Link href="#">
|
||||
悬浮以查看下划线
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">始终显示下划线</p>
|
||||
<Link class="underline" href="#">
|
||||
下划线始终可见
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">无下划线</p>
|
||||
<Link class="no-underline" href="#">
|
||||
不带任何下划线的链接
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">调整下划线偏移</p>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Link class="underline-offset-1" href="#">
|
||||
偏移 1(1px 间距)
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
<Link class="underline-offset-2" href="#">
|
||||
偏移 2(2px 间距)
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
<Link class="underline-offset-3" href="#">
|
||||
偏移 3(3px 间距)
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
<Link class="underline-offset-4" href="#">
|
||||
偏移 4(4px 间距)
|
||||
<LinkIcon />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Spinner />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
|
||||
const COLOR_LABELS = {
|
||||
accent: "强调",
|
||||
current: "当前",
|
||||
danger: "危险",
|
||||
success: "成功",
|
||||
warning: "警告",
|
||||
} as const;
|
||||
|
||||
const colors = ["current", "accent", "success", "warning", "danger"] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-8">
|
||||
<div
|
||||
v-for="color in colors"
|
||||
:key="color"
|
||||
class="flex flex-col items-center gap-2"
|
||||
>
|
||||
<Spinner :color="color" />
|
||||
<span class="text-xs text-muted">{{ COLOR_LABELS[color] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center gap-4 rounded-xl border border-border bg-surface px-5 py-4"
|
||||
>
|
||||
<Spinner class="text-accent" size="sm" />
|
||||
<Spinner class="text-muted" size="md" />
|
||||
<Spinner class="text-success" size="lg" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
|
||||
const SIZE_LABELS = {
|
||||
lg: "大",
|
||||
md: "中",
|
||||
sm: "小",
|
||||
xl: "特大",
|
||||
} as const;
|
||||
|
||||
const sizes = ["sm", "md", "lg", "xl"] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-8">
|
||||
<div
|
||||
v-for="size in sizes"
|
||||
:key="size"
|
||||
class="flex flex-col items-center gap-2"
|
||||
>
|
||||
<Spinner :size="size" />
|
||||
<span class="text-xs text-muted">{{ SIZE_LABELS[size] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-8">
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<Spinner
|
||||
class="animate-[spin_1.5s_linear_infinite] motion-reduce:animate-none"
|
||||
/>
|
||||
<span class="text-xs text-muted">慢速</span>
|
||||
</div>
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<Spinner />
|
||||
<span class="text-xs text-muted">默认</span>
|
||||
</div>
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<Spinner
|
||||
class="animate-[spin_0.4s_linear_infinite] motion-reduce:animate-none"
|
||||
/>
|
||||
<span class="text-xs text-muted">快速</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Surface } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
|
||||
variant="default"
|
||||
>
|
||||
<h3 class="text-base font-semibold text-foreground">表面内容</h3>
|
||||
<p class="text-sm text-muted">这是默认表面变体,使用 bg-surface 样式。</p>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Surface } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Surface
|
||||
class="w-full max-w-sm rounded-xl border border-accent/15 bg-linear-to-br from-accent/8 via-surface to-surface-secondary p-4"
|
||||
variant="default"
|
||||
>
|
||||
<h3 class="text-sm font-semibold text-foreground">账单概览</h3>
|
||||
<p class="text-sm text-muted">在此查看发票和支付方式。</p>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { Surface } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">默认</p>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
|
||||
variant="default"
|
||||
>
|
||||
<h3 class="text-base font-semibold text-foreground">表面内容</h3>
|
||||
<p class="text-sm text-muted">
|
||||
这是默认表面变体,使用 bg-surface 样式。
|
||||
</p>
|
||||
</Surface>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">次要</p>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
|
||||
variant="secondary"
|
||||
>
|
||||
<h3 class="text-base font-semibold text-foreground">表面内容</h3>
|
||||
<p class="text-sm text-muted">
|
||||
这是次要表面变体,使用 bg-surface-secondary 样式。
|
||||
</p>
|
||||
</Surface>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">第三</p>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
|
||||
variant="tertiary"
|
||||
>
|
||||
<h3 class="text-base font-semibold text-foreground">表面内容</h3>
|
||||
<p class="text-sm text-muted">
|
||||
这是第三表面变体,使用 bg-surface-tertiary 样式。
|
||||
</p>
|
||||
</Surface>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">透明</p>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-3 rounded-3xl border p-6"
|
||||
variant="transparent"
|
||||
>
|
||||
<h3 class="text-base font-semibold text-foreground">表面内容</h3>
|
||||
<p class="text-sm text-muted">
|
||||
这是透明表面变体,无背景,适用于遮罩层和自定义背景的卡片。
|
||||
</p>
|
||||
</Surface>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Surface, TextArea } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Surface
|
||||
class="flex min-w-[320px] flex-col gap-4 rounded-3xl p-6"
|
||||
variant="default"
|
||||
>
|
||||
<Input placeholder="使用次要变体的输入框" variant="secondary" />
|
||||
<TextArea placeholder="使用次要变体的文本域" variant="secondary" />
|
||||
</Surface>
|
||||
</template>
|
||||
Reference in New Issue
Block a user