Zubra UI
Code for
GitHub

dashboard-shell

An app's frame: a sidebar of sections, a top bar with the page title and a user menu, and the page in the middle. In a narrow space it folds the sidebar behind a Menu button, measuring itself rather than the screen.

12 events this month
48 people signed up
$1,240 raised

Try it: events appear here (currentchange, menuselect).

Source: dashboard-shell.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/dashboard-shell.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/dashboard-shell.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/dashboard-shell.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/dashboard-shell.json
One file, no dependencies (9.3 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/dashboard-shell.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/dashboard-shell.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/dashboard-shell.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/dashboard-shell.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/dashboard-shell.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/dashboard-shell.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/dashboard-shell.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/dashboard-shell.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/dashboard-shell.js"></script>

The compiled install writes src/components/zubra/dashboard-shell.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 , with the plain elements of the components it's made of; it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<dashboard-shell product="Planner" user="Maya Chen">
  <div class="demo-stats">
    <div class="demo-box"><strong>12</strong> events this month</div>
    <div class="demo-box"><strong>48</strong> people signed up</div>
    <div class="demo-box"><strong>$1,240</strong> raised</div>
  </div>
</dashboard-shell>

<script type="module">
  import './components/zubra/dashboard-shell.js';

  const element = document.querySelector('dashboard-shell');
  element.nav = [
    { id: 'overview', label: 'Overview' },
    { id: 'events', label: 'Events' },
    { id: 'people', label: 'People' },
    { id: 'settings', label: 'Settings' },
  ];
  element.current = 'overview';
  element.menu = [
    { value: 'profile', label: 'Profile' },
    { value: 'signout', label: 'Sign out' },
  ];
  element.addEventListener('currentchange', (event) => console.log('currentchange', event.detail));
  element.addEventListener('menuselect', (event) => console.log('menuselect', event.detail));
</script>
Example.jsx
import './components/zubra/dashboard-shell.js';

const nav = [
  { id: 'overview', label: 'Overview' },
  { id: 'events', label: 'Events' },
  { id: 'people', label: 'People' },
  { id: 'settings', label: 'Settings' },
];
const current = 'overview';
const menu = [
  { value: 'profile', label: 'Profile' },
  { value: 'signout', label: 'Sign out' },
];

export function DashboardShellExample() {
  return (
    <dashboard-shell
      product="Planner"
      user="Maya Chen"
      nav={nav}
      current={current}
      menu={menu}
      oncurrentchange={(event) => console.log('currentchange', event.detail)}
      onmenuselect={(event) => console.log('menuselect', event.detail)}
    >
      <div className="demo-stats">
        <div className="demo-box"><strong>12</strong> events this month</div>
        <div className="demo-box"><strong>48</strong> people signed up</div>
        <div className="demo-box"><strong>$1,240</strong> raised</div>
      </div>
    </dashboard-shell>
  );
}
Example.vue
<script setup>
import './components/zubra/dashboard-shell.js';
const nav = [
  { id: 'overview', label: 'Overview' },
  { id: 'events', label: 'Events' },
  { id: 'people', label: 'People' },
  { id: 'settings', label: 'Settings' },
];
const current = 'overview';
const menu = [
  { value: 'profile', label: 'Profile' },
  { value: 'signout', label: 'Sign out' },
];
const onCurrentchange = (event) => console.log('currentchange', event.detail);
const onMenuselect = (event) => console.log('menuselect', event.detail);
</script>

<template>
  <dashboard-shell
    product="Planner"
    user="Maya Chen"
    :nav.prop="nav"
    :current.prop="current"
    :menu.prop="menu"
    @currentchange="onCurrentchange"
    @menuselect="onMenuselect"
  >
    <div class="demo-stats">
      <div class="demo-box"><strong>12</strong> events this month</div>
      <div class="demo-box"><strong>48</strong> people signed up</div>
      <div class="demo-box"><strong>$1,240</strong> raised</div>
    </div>
  </dashboard-shell>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/dashboard-shell.js';
  const nav = [
    { id: 'overview', label: 'Overview' },
    { id: 'events', label: 'Events' },
    { id: 'people', label: 'People' },
    { id: 'settings', label: 'Settings' },
  ];
  const current = 'overview';
  const menu = [
    { value: 'profile', label: 'Profile' },
    { value: 'signout', label: 'Sign out' },
  ];
</script>

<dashboard-shell
  product="Planner"
  user="Maya Chen"
  {nav}
  {current}
  {menu}
  oncurrentchange={(event) => console.log('currentchange', event.detail)}
  onmenuselect={(event) => console.log('menuselect', event.detail)}
>
  <div class="demo-stats">
    <div class="demo-box"><strong>12</strong> events this month</div>
    <div class="demo-box"><strong>48</strong> people signed up</div>
    <div class="demo-box"><strong>$1,240</strong> raised</div>
  </div>
</dashboard-shell>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/dashboard-shell.js';

@Component({
  selector: 'app-dashboard-shell-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <dashboard-shell
      product="Planner"
      user="Maya Chen"
      [nav]="nav"
      [current]="current"
      [menu]="menu"
      (currentchange)="onCurrentchange($event)"
      (menuselect)="onMenuselect($event)"
    >
      <div class="demo-stats">
        <div class="demo-box"><strong>12</strong> events this month</div>
        <div class="demo-box"><strong>48</strong> people signed up</div>
        <div class="demo-box"><strong>$1,240</strong> raised</div>
      </div>
    </dashboard-shell>
  `,
})
export class DashboardShellExample {
  nav = [
    { id: 'overview', label: 'Overview' },
    { id: 'events', label: 'Events' },
    { id: 'people', label: 'People' },
    { id: 'settings', label: 'Settings' },
  ];

  current = 'overview';

  menu = [
    { value: 'profile', label: 'Profile' },
    { value: 'signout', label: 'Sign out' },
  ];

  onCurrentchange(event: Event) {
    console.log('currentchange', (event as CustomEvent).detail);
  }

  onMenuselect(event: Event) {
    console.log('menuselect', (event as CustomEvent).detail);
  }
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
productstring""
headingstring""
nav
property only
{ id, label }[][]
currentstring""
menu
property only
{ value, label }[][]
userstring"Account"
Events
EventWhen
currentchangeA section was chosen; detail is its id.
menuselectA user menu item was picked; detail is its value.
Slots
SlotFor
(default)The page's content.
actionsButtons in the top bar, before the user menu.

Size

2.2 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 21.0 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