empty-state
What a list or page shows when there's nothing in it yet: a heading that says what's missing, a line on what it's for, and the action that fills it. Turns an empty screen into a next step.
This one has no events: it shows what it's given.
Source: empty-state.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/empty-state.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/empty-state.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/empty-state.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/empty-state.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/empty-state.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/empty-state.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/empty-state.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/empty-state.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/empty-state.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/empty-state.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/empty-state.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/empty-state.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/empty-state.js"></script>The compiled install writes src/components/zubra/empty-state.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<empty-state heading="No invoices yet">
Invoices you send show up here, with who has paid.
<action-button slot="actions">Create an invoice</action-button>
</empty-state>
<script type="module">
import './components/zubra/empty-state.js';
import './components/zubra/action-button.js';
</script>import './components/zubra/empty-state.js';
import './components/zubra/action-button.js';
export function EmptyStateExample() {
return (
<empty-state heading="No invoices yet">
Invoices you send show up here, with who has paid.
<action-button slot="actions">Create an invoice</action-button>
</empty-state>
);
}<script setup>
import './components/zubra/empty-state.js';
import './components/zubra/action-button.js';
</script>
<template>
<empty-state heading="No invoices yet">
Invoices you send show up here, with who has paid.
<action-button slot="actions">Create an invoice</action-button>
</empty-state>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/empty-state.js';
import './components/zubra/action-button.js';
</script>
<empty-state heading="No invoices yet">
Invoices you send show up here, with who has paid.
<action-button slot="actions">Create an invoice</action-button>
</empty-state>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/empty-state.js';
import './components/zubra/action-button.js';
@Component({
selector: 'app-empty-state-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<empty-state heading="No invoices yet">
Invoices you send show up here, with who has paid.
<action-button slot="actions">Create an invoice</action-button>
</empty-state>
`,
})
export class EmptyStateExample {
}API
| Property | Type | Default |
|---|---|---|
heading | string | "Nothing here yet" |
| Slot | For |
|---|---|
(default) | The line under the heading. |
actions | The button or link that fills it. |
heading | The heading (defaults to heading). |
icon | A small picture above the heading (defaults to a simple outline). |
Size
0.9 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.2 KB.