组件

Empty

What a page says when there is nothing on it yet: media, a title in the script font, a line of explanation and an action. The media can be an icon on a slip of paper, Stubby the pencil stub in one of his poses, or a doodle; a `border` draws the sketched, dashed placeholder frame.

安装

terminal
npx shadcn@latest add @wobko/empty

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Icon tile

The upstream layout: media, title, description and an action. `variant="icon"` puts the icon on a little slip of paper with a hatched shadow; the title is in the script font.

Stubby

`pose` asks for Stubby, the pencil stub who does the drawing: `search` for no results, `sleep` for a quiet day, `unplug` for offline, and the rest of the poses as they are drawn (see the props). Media is decorative, so the title carries the meaning.

Placeholder frame

`border` in `className` asks for the sketched dashed frame, with a tick at each corner where the hand marked out the rectangle first. It replaces the CSS border. Here it is a working drop target: drag files over it (it lights up), or use the button; a doodle is the media, and `doodle` takes any name from the Doodle component.

Search with no results

A real use: a filterable list that turns into an empty state when nothing matches, with an action that puts the list back. Type something that is not a name.

Four icons

shadcn's `empty-icon`: four bare empty states in a two-column grid, each an icon tile, a title and one line. No action, so the page just says what it is missing.

Avatar

shadcn's `empty-avatar`: `variant="default"` leaves the media bare, so any element can stand there. A face here (initials on marker; the photo of the original is left out so the page needs no network).

Avatar group

shadcn's `empty-avatar-group`: three overlapping faces in the media slot, sized and ringed from the parent with `*:data-[slot=avatar]` selectors, and an invite button.

Input group

shadcn's `empty-input-group`: a 404 with no media at all, a search field with a magnifier and a `/` keycap, and a support link under it.

Outline

shadcn's `empty-outline`: `border border-dashed` on the root. Here the border is the sketched placeholder frame: a dashed line drawn round the space, as if the thing were to be pasted in.

Background

shadcn's `empty-background`: a soft wash that fades from the muted tone into the paper. Any background utility goes on the root; it is a plain class, nothing is redrawn.

API 参考

Empty

A centered column (gap 6, padding 24, 48 from `md`). Add `border` to `className` and the CSS border becomes a hand-drawn dashed frame with corner ticks; without it nothing is drawn.

属性类型默认值说明
seedstring | number-Pins the hand of the frame. Default: derived from useId().

EmptyMedia

The picture above the words (`data-slot="empty-icon"`, as upstream). Children go inside it as they are; `pose` and `doodle` are shortcuts for the art components.

属性类型默认值说明
variant"default" | "icon""default"`icon` = a 44 px slip of paper with a hatched shadow and the icon (24 px) on it.
pose"idle" | "wave" | "think" | "write" | "sketch" | "celebrate" | "oops" | "shrug" | "sleep" | "peek" | "point" | "carry" | "halt" | "search" | "unplug"-Stubby, in a pose. Good matches: `search` no results, `sleep` nothing scheduled, `unplug` offline, `oops` an error, `shrug` not found, `celebrate` all done, `peek` loading, `think` working on it. A pose that has not been drawn yet renders nothing.
doodlestring-A doodle by name (`paper-plane`, `cat-face`, `balloon`, `sparkle`...).
sizenumber96 (Stubby), 80 (doodle)Pixels tall. Stubby is a sticker whose box includes his white border, redrawn under 28, under 56 and from 140; the master starts at 56. Doodles are redrawn at 48 and below.

无障碍

  • Empty is a plain group of divs, as upstream; the title is not a heading unless you make it one (put an `<h2>` inside `EmptyTitle`, or give the Empty a role and a name).
  • Stubby, doodles and the icon tile are decoration (aria-hidden): the title and description carry the meaning. If the state is announced dynamically (search results going to none), put `role="status"` on the Empty.
  • Ink on paper is 14:1, the muted description 8.9:1. The dashed frame is decoration and carries no information.
  • Buttons and links in EmptyContent are ordinary controls with their own focus rings.
  • The frame and the tile are hairline in calm density, and hidden in Windows high contrast in favour of a plain outline.

源码

CLI 会复制进你项目的文件。

正在加载源码