No packages found

Get started by installing your first package.

$npm install @cloudflare/kumo
import { Empty, Button } from "@cloudflare/kumo";
import { PackageIcon, CodeIcon, GlobeIcon } from "@phosphor-icons/react";

export function EmptyDemo() {
  return (
    <Empty
      icon={<PackageIcon size={48} />}
      title="No packages found"
      description="Get started by installing your first package."
      commandLine="npm install @cloudflare/kumo"
      contents={
        <div className="flex items-center gap-2">
          <Button icon={<CodeIcon />}>See examples</Button>
          <Button icon={<GlobeIcon />} variant="primary">
            View documentation
          </Button>
        </div>
      }
    />
  );
}

安装

import { Empty } from "@cloudflare/kumo";

用法

import { Empty } from "@cloudflare/kumo";
import { PackageIcon } from "@phosphor-icons/react";

export default function Example() {
  return (
    <Empty
      icon={<PackageIcon size={48} />}
      title="No packages found"
      description="Get started by installing your first package."
      commandLine="npm install @kumo/ui"
    />
  );
}

示例

基本

No results found

Try adjusting your search or filter to find what you're looking for.

import { Empty } from "@cloudflare/kumo";

export function EmptyBasicDemo() {
  return (
    <Empty
      title="No results found"
      description="Try adjusting your search or filter to find what you're looking for."
    />
  );
}

尺寸

空状态提供三种尺寸,以适应不同的容器场景。

Small

No data available

There is no data to display.

Base

No data available

There is no data to display.

Large

No data available

There is no data to display.

import { Empty } from "@cloudflare/kumo";
import { Database } from "@phosphor-icons/react";

export function EmptySizesDemo() {
  return (
    <div className="flex flex-col gap-8">
      <div>
        <p className="mb-2 text-sm text-kumo-subtle">Small</p>
        <Empty
          size="sm"
          icon={<Database size={32} className="text-kumo-inactive" />}
          title="No data available"
          description="There is no data to display."
        />
      </div>
      <div>
        <p className="mb-2 text-sm text-kumo-subtle">Base</p>
        <Empty
          size="base"
          icon={<Database size={48} className="text-kumo-inactive" />}
          title="No data available"
          description="There is no data to display."
        />
      </div>
      <div>
        <p className="mb-2 text-sm text-kumo-subtle">Large</p>
        <Empty
          size="lg"
          icon={<Database size={64} className="text-kumo-inactive" />}
          title="No data available"
          description="There is no data to display."
        />
      </div>
    </div>
  );
}

带命令行

包含可复制的命令,帮助用户快速上手。

No projects found

Get started by creating your first project using the command below.

$npm create kumo-project
import { Empty } from "@cloudflare/kumo";
import { FolderOpen } from "@phosphor-icons/react";

export function EmptyWithCommandDemo() {
  return (
    <Empty
      icon={<FolderOpen size={48} className="text-kumo-inactive" />}
      title="No projects found"
      description="Get started by creating your first project using the command below."
      commandLine="npm create kumo-project"
    />
  );
}

带操作按钮

使用 contents 属性添加自定义操作按钮。

No connection

Unable to connect to the server. Please check your connection and try again.

import { Empty, Button } from "@cloudflare/kumo";
import { CloudSlash } from "@phosphor-icons/react";

export function EmptyWithActionsDemo() {
  return (
    <Empty
      icon={<CloudSlash size={48} className="text-kumo-inactive" />}
      title="No connection"
      description="Unable to connect to the server. Please check your connection and try again."
      contents={
        <div className="flex gap-2">
          <Button variant="primary">Retry</Button>
          <Button variant="secondary">Go Back</Button>
        </div>
      }
    />
  );
}

极简模式

最少只需标题即可。

Nothing here

import { Empty } from "@cloudflare/kumo";

export function EmptyMinimalDemo() {
  return <Empty title="Nothing here" />;
}

API 参考

PropTypeDefaultDescription
size"sm" | "base" | "lg""base"

空状态容器的大小。

  • "sm" — 适用于较小容器的紧凑空状态
  • "base" — 默认空状态大小
  • "lg" — 用于突出放置的大型空状态
iconReactNode-

显示在标题上方的装饰性图标(例如来自 @phosphor-icons/react 的图标)。

title*string-

空状态的主要标题文本。

descriptionstring-

显示在标题下方的次要描述文本。

commandLinestring-

显示在可复制代码块中的 Shell 命令。

contentsReactNode-

描述下方渲染的额外内容(按钮、链接)。

classNamestring-

通过 cn() 合并的额外 CSS 类。