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.
Try it: events appear here (currentchange, menuselect).
Source: dashboard-shell.zb, and its registry item.
Install
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
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
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
<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
<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>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>
);
}<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('-') } } }) --><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>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
| Property | Type | Default |
|---|---|---|
product | string | "" |
heading | string | "" |
navproperty only | { id, label }[] | [] |
current | string | "" |
menuproperty only | { value, label }[] | [] |
user | string | "Account" |
| Event | When |
|---|---|
currentchange | A section was chosen; detail is its id. |
menuselect | A user menu item was picked; detail is its value. |
| Slot | For |
|---|---|
(default) | The page's content. |
actions | Buttons 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.