🌐 Nodejs.cn

使用 Empty 组件来显示空状态。

No Projects Yet
You haven't created any projects yet. Get started by creating your first project.
Learn More
import { Button } from "@/components/ui/button"
import {
  Empty,

安装

🌐 Installation

pnpm dlx shadcn@latest add empty

用法

🌐 Usage

import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"
<Empty>
  <EmptyHeader>
    <EmptyMedia variant="icon">
      <Icon />
    </EmptyMedia>
    <EmptyTitle>No data</EmptyTitle>
    <EmptyDescription>No data found</EmptyDescription>
  </EmptyHeader>
  <EmptyContent>
    <Button>Add data</Button>
  </EmptyContent>
</Empty>

示例

🌐 Examples

大纲

🌐 Outline

使用 border 工具类创建轮廓空状态。

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

Cloud Storage Empty
Upload files to your cloud storage to access them anywhere.
import { Button } from "@/components/ui/button"
import {
  Empty,

背景

🌐 Background

使用 bg-*bg-gradient-* 工具为空状态添加背景。

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

No Notifications
You're all caught up. New notifications will appear here.
import { Button } from "@/components/ui/button"
import {
  Empty,

头像

🌐 Avatar

使用 EmptyMedia 组件在空状态下显示头像。

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

LR
User Offline
This user is currently offline. You can leave a message to notify them or try again later.
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import {

阿凡达集团

🌐 Avatar Group

使用 EmptyMedia 组件在空状态下显示头像组。

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

CNLRER
No Team Members
Invite your team to collaborate on this project.
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import {

InputGroup

你可以将 InputGroup 组件添加到 EmptyContent 组件中。

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

404 - Not Found
The page you're looking for doesn't exist. Try searching for what you need below.
/
Need help? Contact support
import {
  Empty,
  EmptyContent,

从右到左

🌐 RTL

要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南

🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.

لا توجد مشاريع بعد
لم تقم بإنشاء أي مشاريع بعد. ابدأ بإنشاء مشروعك الأول.
تعرف على المزيد
"use client"

import * as React from "react"

API参考

🌐 API Reference

🌐 Empty

空状态的主要组件。封装 EmptyHeaderEmptyContent 组件。

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

属性类型默认值
classNamestring
<Empty>
  <EmptyHeader />
  <EmptyContent />
</Empty>

EmptyHeader

EmptyHeader 组件封装了空的媒体、标题和描述。

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

属性类型默认值
classNamestring
<EmptyHeader>
  <EmptyMedia />
  <EmptyTitle />
  <EmptyDescription />
</EmptyHeader>

EmptyMedia

使用 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.

属性类型默认值
variant"default" | "icon"default
classNamestring
<EmptyMedia variant="icon">
  <Icon />
</EmptyMedia>
<EmptyMedia>
  <Avatar>
    <AvatarImage src="..." />
    <AvatarFallback>CN</AvatarFallback>
  </Avatar>
</EmptyMedia>

EmptyTitle

使用 EmptyTitle 组件显示空状态的标题。

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

属性类型默认值
classNamestring
<EmptyTitle>No data</EmptyTitle>

EmptyDescription

使用 EmptyDescription 组件显示空状态的描述。

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

属性类型默认值
classNamestring
<EmptyDescription>You do not have any notifications.</EmptyDescription>

EmptyContent

使用 EmptyContent 组件来显示空状态的内容,例如按钮、输入框或链接。

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

属性类型默认值
classNamestring
<EmptyContent>
  <Button>Add Project</Button>
</EmptyContent>