feat: add Surface, Link and Spinner components
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user