EmptyState 空状态
反馈组件
当前没有数据时的占位展示,可搭配引导操作。
何时使用
需要空状态功能时使用本组件。
代码示例
基础用法
tsx
import { EmptyState } from "@chaos_team/chaos-ui/ui"
export function Basic() {
return <EmptyState>Default</EmptyState>
}尺寸
tsx
{/* 尺寸对照 */}
<div className="flex flex-wrap items-center gap-3">
<EmptyState size="sm">Sm</EmptyState>
<EmptyState size="default">Default</EmptyState>
<EmptyState size="lg">Lg</EmptyState>
</div>样式变体
尺寸
| Size | 说明 | 默认 |
|---|---|---|
default | 默认尺寸 | ✓ |
sm | 小号 | |
lg | 大号 |
API / Props
EmptyState
| Prop | Type | Default | 说明 |
|---|---|---|---|
className | string | — | 自定义样式类名 |
icon | React.ReactNode | — | Icon element |
title | React.ReactNode | — | Title text |
description | React.ReactNode | — | Description text |
action | React.ReactNode | — | Action element (button, link, etc.) |
| ...rest | React.ComponentProps<"div"> | — | 透传 <div> 原生属性 |
注意事项
- CVA 变体: 通过
class-variance-authority管理样式变体,类型安全。变体对象可导出复用。 - 原生属性: 继承所有
<div>原生 HTML 属性。
📘 完整交互式示例与控件属性请查看 Storybook 文档。