Zubra UI
Code for
GitHub

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.

Invoices you send show up here, with who has paid. Create an invoice

This one has no events: it shows what it's given.

Source: empty-state.zb, and its registry item.

Install

Compiled (any project)
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
One file, no dependencies (3.5 KB gzipped)
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
.zb source (to edit it with Zubra)
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
No build: a script tag, straight from this site
HTML
<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

index.html
<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>
Example.jsx
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>
  );
}
Example.vue
<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('-') } } }) -->
Example.svelte
<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>
example.component.ts
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

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
headingstring"Nothing here yet"
Slots
SlotFor
(default)The line under the heading.
actionsThe button or link that fills it.
headingThe heading (defaults to heading).
iconA 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.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour