# 空状态 · JGuang UI

> 在没有数据时提供说明和下一步操作。

- 页面: https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty
- 改编自: shadcn/ui 文档 (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c
- 说明：正文保留英文原文。

> 示例 `empty-demo`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Copy and paste the following code into your project.


[View complete source: components/ui/empty.tsx](/r/jguang-ui/base/empty.json)


### Update the import paths to match your project setup.


## Usage

```tsx
import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"
```

```tsx
<Empty>
  <EmptyHeader>
    <EmptyMedia variant="icon">
      <Icon />
    </EmptyMedia>
    <EmptyTitle>No data</EmptyTitle>
    <EmptyDescription>No data found</EmptyDescription>
  </EmptyHeader>
  <EmptyContent>
    <Button>Add data</Button>
  </EmptyContent>
</Empty>
```

## Composition

Use the following composition to build an `Empty` state:

```text
Empty
├── EmptyHeader
│   ├── EmptyMedia
│   ├── EmptyTitle
│   └── EmptyDescription
└── EmptyContent
```

## Outline

Use the `border` utility class to create an outline empty state.


> 示例 `empty-outline`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## Background

Use the `bg-*` and `bg-gradient-*` utilities to add a background to the empty state.


> 示例 `empty-background`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## Avatar

Use the `EmptyMedia` component to display an avatar in the empty state.


> 示例 `empty-avatar`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## Avatar Group

Use the `EmptyMedia` component to display an avatar group in the empty state.


> 示例 `empty-avatar-group`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## InputGroup

You can add an `InputGroup` component to the `EmptyContent` component.


> 示例 `empty-input-group`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> 示例 `empty-rtl`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/base/empty


## API Reference

### Empty

The main component of the empty state. Wraps the `EmptyHeader` and `EmptyContent` components.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` |         |

```tsx
<Empty>
  <EmptyHeader />
  <EmptyContent />
</Empty>
```

### EmptyHeader

The `EmptyHeader` component wraps the empty media, title, and description.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` |         |

```tsx
<EmptyHeader>
  <EmptyMedia />
  <EmptyTitle />
  <EmptyDescription />
</EmptyHeader>
```

### EmptyMedia

Use the `EmptyMedia` component to display the media of the empty state such as an icon or an image. You can also use it to display other components such as an avatar.

| Prop        | Type                  | Default   |
| ----------- | --------------------- | --------- |
| `variant`   | `"default" \| "icon"` | `default` |
| `className` | `string`              |           |

```tsx
<EmptyMedia variant="icon">
  <Icon />
</EmptyMedia>
```

```tsx
<EmptyMedia>
  <Avatar>
    <AvatarImage src="..." />
    <AvatarFallback>CN</AvatarFallback>
  </Avatar>
</EmptyMedia>
```

### EmptyTitle

Use the `EmptyTitle` component to display the title of the empty state.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` |         |

```tsx
<EmptyTitle>No data</EmptyTitle>
```

### EmptyDescription

Use the `EmptyDescription` component to display the description of the empty state.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` |         |

```tsx
<EmptyDescription>You do not have any notifications.</EmptyDescription>
```

### EmptyContent

Use the `EmptyContent` component to display the content of the empty state such as a button, input or a link.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` |         |

```tsx
<EmptyContent>
  <Button>Add Project</Button>
</EmptyContent>
```

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
