---
title: "Icon Stack"
description: "Used to display a decorative stacked icon."
url: https://weme-ui.github.io/slim/components/icon-stack.md
---
# Icon Stack

图标下面垫几层纸片。空态、入口页能用。

## Installation

```bash
pnpm dlx @weme-ui/weme-ui add icon-stack
```

## Usage

```vue
<script lang="ts" setup>
import IconStack from '../icon-stack.vue'
</script>

<template>
  <div class="flex flex-wrap gap-4 items-center">
    <IconStack icon="ri:folder-line" />
  </div>
</template>
```

## Props

| 属性       | 说明                                                                                                            | 类型                                                                   | 默认值  |
| ---------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------- |
| `as`       | 渲染为的元素或组件（Reka UI `Primitive`）                                                                       | `AsTag \| Component`                                                   | `'div'` |
| `asChild`  | 合并到子元素上渲染（Reka UI composition）                                                                       | `boolean`                                                              | `false` |
| `icon`     | 前景图标名称或 Iconify 图标数据                                                                                 | `IconifyIconProps['icon']`                                             | —       |
| `color`    | 层叠背景与图标色彩                                                                                              | `'accent' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'error'` | —       |
| `size`     | 尺寸                                                                                                            | `'xs' \| 'sm' \| 'md' \| 'lg'`                                         | `'sm'`  |
| `contentX` | 前景内容水平位置（CSS 长度，写入 CSS 变量）                                                                     | `string`                                                               | `'71%'` |
| `contentY` | 前景内容垂直位置（CSS 长度，写入 CSS 变量）                                                                     | `string`                                                               | `'58%'` |
| `class`    | 根节点额外 class                                                                                                | `any`                                                                  | —       |
| `ui`       | 覆盖 slots 样式（`root` / `layerWrapper` / `ellipse` / `iconWrapper` / `icon`）。`layer` 在类型里，模板没有用上 | `Partial<IconStackStyleSlots>`                                         | —       |

## Slots

| 插槽      | 说明                                                  |
| --------- | ----------------------------------------------------- |
| `default` | 自定义前景内容；未提供且传入 `icon` 时渲染内置 `Icon` |

## Accessibility

默认是 `div`（Reka UI `Primitive`）。后面那些 SVG 是装饰，`aria-hidden="true"`。前景图标有含义的话，旁边写字，或用 `default` 插槽自己放。

## Examples

### Colors

```vue
<script lang="ts" setup>
import IconStack from '../icon-stack.vue'
</script>

<template>
  <div class="flex flex-wrap gap-4 items-center">
    <IconStack icon="ri:folder-line" color="accent" />
    <IconStack icon="ri:folder-line" color="neutral" />
    <IconStack icon="ri:information-line" color="info" />
    <IconStack icon="ri:checkbox-circle-line" color="success" />
    <IconStack icon="ri:alert-line" color="warning" />
    <IconStack icon="ri:error-warning-line" color="error" />
  </div>
</template>
```

### Sizes

```vue
<script lang="ts" setup>
import IconStack from '../icon-stack.vue'
</script>

<template>
  <div class="flex flex-wrap gap-4 items-end">
    <IconStack icon="ri:folder-line" color="accent" size="xs" />
    <IconStack icon="ri:folder-line" color="accent" size="sm" />
    <IconStack icon="ri:folder-line" color="accent" size="md" />
    <IconStack icon="ri:folder-line" color="accent" size="lg" />
  </div>
</template>
```