Blocks
Dashboard
A whole dashboard from data: a sidebar with your brand, navigation and the signed-in user, a top bar, and a page header over your content. Pick the sidebar, floating or inset layout.
The dashboard shell is the frame of an app. Give it your brand, your navigation as data and the signed-in user, and it lays out the sidebar, the top bar and the page header. Your content goes underneath: stats, charts, tables, anything.
It installs as a block, so the code lands in your project and is yours to change.
Preview
Section titled “Preview”<style>
.dashboard-frame nana-dashboard-shell {
height: 100%;
}
.dashboard-frame nana-dashboard-shell::part(layout) {
height: 100%;
min-height: 0;
}
.dashboard-frame nana-dashboard-shell::part(sidebar) {
height: 100%;
}
.dashboard-frame nana-dashboard-shell::part(page) {
min-height: 0;
overflow: auto;
}
</style>
<div
class="dashboard-frame"
style="
height: 40rem;
width: 100%;
overflow: hidden;
border: 1px solid var(--nana-surface-border);
border-radius: 0.5rem;
"
>
<nana-dashboard-shell
id="dashboard-demo"
brand="Nana Insurance"
heading="Overview"
description="How the book is doing this month."
level="2"
label="Dashboard"
>
<nana-input
slot="search"
type="search"
aria-label="Search"
placeholder="Search"
style="width: 100%; max-width: 24rem"
></nana-input>
<nana-icon-button
slot="toolbar"
name="bell"
label="Notifications"
></nana-icon-button>
<nana-button slot="actions" variant="ghost">Export</nana-button>
<nana-button slot="actions">New claim</nana-button>
<p style="margin: 0">Your content goes here: stats, charts and tables.</p>
</nana-dashboard-shell>
</div>
<script type="module">
const shell = document.getElementById("dashboard-demo");
shell.nav = [
{
label: "Workspace",
items: [
{ label: "Overview", href: "#", icon: "home", active: true },
{ label: "Analytics", href: "#", icon: "chart-bar" },
{
label: "Claims",
icon: "document-text",
badge: 12,
items: [
{ label: "Motor", href: "#" },
{ label: "Medical", href: "#" },
],
},
{ label: "Policies", href: "#", icon: "shield-check" },
],
},
{
label: "Finance",
items: [{ label: "Payments", href: "#", icon: "banknotes" }],
},
];
shell.user = { name: "Amina Otieno", detail: "Claims lead" };
</script> <script lang="ts">
import { AreaChart } from 'layerchart';
import { bellIcon, magnifyingGlassIcon } from '@nana-tec/ui-core/heroicons';
import {
NanaButton,
NanaCard,
NanaCardContent,
NanaCardDescription,
NanaCardHeader,
NanaCardTitle,
NanaChartContainer,
NanaChartLegend,
NanaDashboardShell,
NanaIcon,
NanaIconButton,
NanaInput,
} from '$lib';
import { NanaDataTable } from '$lib/blocks/data-table';
import { NanaStatsCards } from '$lib/blocks/stats-cards';
import {
chartConfig,
claims,
columns,
frame,
monthLabel,
monthly,
navFor,
stats,
user,
} from './dashboard-data';
</script>
<div class={frame}>
<NanaDashboardShell
brand="Nana Insurance"
nav={navFor('Overview')}
{user}
heading="Overview"
description="How the book is doing this month."
level={2}
label="Dashboard"
>
{#snippet search()}
<NanaInput class="w-full max-w-sm" type="search" aria-label="Search" placeholder="Search">
{#snippet prefix()}<NanaIcon icon={magnifyingGlassIcon} />{/snippet}
</NanaInput>
{/snippet}
{#snippet toolbar()}
<NanaIconButton icon={bellIcon} label="Notifications" />
{/snippet}
{#snippet actions()}
<NanaButton variant="ghost">Export</NanaButton>
<NanaButton>New claim</NanaButton>
{/snippet}
<NanaStatsCards {stats} columns={2} />
<NanaCard>
<NanaCardHeader>
<NanaCardTitle>Premiums and claims</NanaCardTitle>
<NanaCardDescription>January to June 2026, KES thousands</NanaCardDescription>
</NanaCardHeader>
<NanaCardContent>
<NanaChartContainer
config={chartConfig}
class="aspect-auto h-64"
aria-label="Premiums and claims paid each month"
>
{#snippet children({ series })}
<AreaChart
data={monthly}
x="month"
{series}
props={{ area: { fillOpacity: 0.2 }, xAxis: { format: monthLabel } }}
/>
{/snippet}
</NanaChartContainer>
<NanaChartLegend config={chartConfig} />
</NanaCardContent>
</NanaCard>
<NanaDataTable rows={claims} {columns} searchKeys={['id', 'customer']} pageSize={5} />
</NanaDashboardShell>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add dashboard-shell --framework web-componentsnpx @nana-tec/ui add dashboard-shell --framework svelteLands in src/lib/blocks/dashboard-shell/, together with the sidebar, top bar, page
header and avatar it is built from. Requires Tailwind v4.
The navigation is a list of groups. Each group has an optional label and its items; an
item has a label, a link, an icon and, if you like, a badge, and it can hold one level of
sub-items. Mark the current page with active.
<script lang="ts"> import { homeIcon, documentTextIcon } from '@nana-tec/ui-core/heroicons'; import { NanaDashboardShell, type DashboardNavGroup } from '$lib/blocks/dashboard-shell';
const nav: DashboardNavGroup[] = [ { label: 'Workspace', items: [ { label: 'Overview', href: '/', icon: homeIcon, active: true }, { label: 'Claims', icon: documentTextIcon, badge: 12, items: [{ label: 'Motor', href: '/claims/motor' }], }, ], }, ];</script>
<NanaDashboardShell brand="Nana Insurance" {nav} user={{ name: 'Amina Otieno', detail: 'Claims lead' }} heading="Overview"> {#snippet search()}<NanaInput type="search" aria-label="Search" />{/snippet} {#snippet toolbar()}<NanaThemeToggle />{/snippet} {#snippet actions()}<NanaButton>New claim</NanaButton>{/snippet} <NanaStatsCards {stats} /></NanaDashboardShell>
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/dashboard-shell";
Copied in with npx @nana-tec/ui add dashboard-shell? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
nav and user are data, so set them from script. Icons are names from the icon set.
<nana-dashboard-shell brand="Nana Insurance" heading="Overview"> <nana-input slot="search" type="search" aria-label="Search"></nana-input> <nana-icon-button slot="toolbar" name="bell" label="Notifications"></nana-icon-button> <nana-button slot="actions">New claim</nana-button> <p>Your content</p></nana-dashboard-shell>
<script type="module"> const shell = document.querySelector('nana-dashboard-shell'); shell.nav = [ { label: 'Workspace', items: [ { label: 'Overview', href: '/', icon: 'home', active: true }, { label: 'Claims', icon: 'document-text', items: [{ label: 'Motor', href: '/claims/motor' }] }, ], }, ]; shell.user = { name: 'Amina Otieno', detail: 'Claims lead' };</script>| Place | Svelte snippet | Web component slot |
|---|---|---|
| Brand mark, in place of the first letter | mark | mark |
| Top bar, after the sidebar trigger | breadcrumb | breadcrumb |
| Middle of the top bar | search | search |
| End of the top bar | toolbar | toolbar |
| Beside the page title | actions | actions |
| Sidebar footer, in place of the user card | footer | footer |
| Under the page header | children | default slot |
Layouts
Section titled “Layouts”variant picks how the sidebar sits beside the page, and collapsible how it folds away,
just as on the sidebar. Everything else stays the same,
so a layout change is one prop.
The sidebar blends into the background and the page sits in a raised, rounded panel.
<script lang="ts">
import { NanaButton, NanaDashboardShell } from '$lib';
import { NanaDataTable } from '$lib/blocks/data-table';
import { NanaStatsCards } from '$lib/blocks/stats-cards';
import { claims, columns, frame, navFor, stats, user } from './dashboard-data';
</script>
<div class={frame}>
<NanaDashboardShell
variant="inset"
brand="Nana Insurance"
nav={navFor('Motor')}
{user}
heading="Motor claims"
description="Claims filed against motor policies, newest first."
level={2}
label="Inset dashboard"
>
{#snippet actions()}<NanaButton>New claim</NanaButton>{/snippet}
<NanaStatsCards stats={stats.slice(2)} columns={2} />
<NanaDataTable rows={claims} {columns} searchKeys={['id', 'customer']} pageSize={5} />
</NanaDashboardShell>
</div> Floating
Section titled “Floating”The sidebar floats as a card in a small gutter.
<script lang="ts">
import { NanaButton, NanaDashboardShell } from '$lib';
import { NanaDataTable } from '$lib/blocks/data-table';
import { claims, columns, frame, navFor, user } from './dashboard-data';
</script>
<div class={frame}>
<NanaDashboardShell
variant="floating"
brand="Nana Insurance"
nav={navFor('Motor')}
{user}
heading="Claims"
description="Every claim, across all covers."
level={2}
label="Floating dashboard"
>
{#snippet actions()}
<NanaButton variant="ghost">Export</NanaButton>
{/snippet}
<NanaDataTable rows={claims} {columns} searchKeys={['id', 'customer']} pageSize={5} />
</NanaDashboardShell>
</div> Analytics
Section titled “Analytics”Charts first, the numbers underneath. The charts take their colours from the theme through the chart container.
<script lang="ts">
import { BarChart, LineChart } from 'layerchart';
import {
NanaCard,
NanaCardContent,
NanaCardDescription,
NanaCardHeader,
NanaCardTitle,
NanaChartContainer,
NanaChartLegend,
NanaDashboardShell,
} from '$lib';
import { NanaStatsCards } from '$lib/blocks/stats-cards';
import { chartConfig, frame, monthLabel, monthly, navFor, stats, user } from './dashboard-data';
</script>
<div class={frame}>
<NanaDashboardShell
brand="Nana Insurance"
nav={navFor('Analytics')}
{user}
heading="Analytics"
description="Premiums against claims over the half year."
level={2}
label="Analytics dashboard"
>
<div class="grid gap-4">
<NanaCard>
<NanaCardHeader>
<NanaCardTitle>Monthly totals</NanaCardTitle>
<NanaCardDescription>KES thousands</NanaCardDescription>
</NanaCardHeader>
<NanaCardContent>
<NanaChartContainer
config={chartConfig}
class="aspect-auto h-56"
aria-label="Premiums and claims paid each month, as bars"
>
{#snippet children({ series })}
<BarChart
data={monthly}
x="month"
{series}
seriesLayout="group"
props={{ xAxis: { format: monthLabel } }}
/>
{/snippet}
</NanaChartContainer>
<NanaChartLegend config={chartConfig} />
</NanaCardContent>
</NanaCard>
<NanaCard>
<NanaCardHeader>
<NanaCardTitle>Trend</NanaCardTitle>
<NanaCardDescription>KES thousands</NanaCardDescription>
</NanaCardHeader>
<NanaCardContent>
<NanaChartContainer
config={chartConfig}
class="aspect-auto h-56"
aria-label="Premiums and claims paid each month, as lines"
>
{#snippet children({ series })}
<LineChart
data={monthly}
x="month"
{series}
props={{ xAxis: { format: monthLabel } }}
/>
{/snippet}
</NanaChartContainer>
<NanaChartLegend config={chartConfig} />
</NanaCardContent>
</NanaCard>
</div>
<NanaStatsCards {stats} columns={2} />
</NanaDashboardShell>
</div> Inside a fixed height
Section titled “Inside a fixed height”The shell fills the screen: the sidebar is as tall as the viewport and the page scrolls with the window. To fit it in a box of its own, such as a preview, let the page scroll inside the box instead.
.frame nana-dashboard-shell { height: 100%; }.frame nana-dashboard-shell::part(layout) { height: 100%; min-height: 0; }.frame nana-dashboard-shell::part(sidebar) { height: 100%; }.frame nana-dashboard-shell::part(page) { min-height: 0; overflow: auto; }The examples on this page wrap the shell in a frame that does this with Tailwind:
<div class="h-[40rem] overflow-hidden [&_[data-nana=sidebar][data-part=root]]:h-full [&_[data-nana=sidebar][data-part=root]]:min-h-0 [&_[data-nana=sidebar][data-part=panel]]:h-full [&_main]:min-h-0 [&_main]:overflow-auto"> <NanaDashboardShell …>…</NanaDashboardShell></div>Phones
Section titled “Phones”Below 768px the sidebar opens as a drawer from the trigger in the top bar, the actions move under the page title, and the padding tightens.
Accessibility
Section titled “Accessibility”- The sidebar is a navigation landmark named by
label, “Main” by default. Give each shell on a page its own name. - The page title is a level-one heading. Set
levelto 2 or 3 when the shell sits inside another page, as it does on this one. - Collapsed to icons, the brand and user names stay readable to screen readers, and each item’s label moves into a tooltip.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
brand | brand | string | '' | The product or company name at the top of the sidebar. |
brandHref | brand-href | string | '' | Where the brand links to, usually the dashboard's home. |
collapsible | collapsible | SidebarCollapsible | 'icon' | How the sidebar collapses: icon, offcanvas or none. |
description | description | string | '' | A short line under the page title. |
heading | heading | string | '' | The page title. |
label | label | string | 'Main' | Accessible name of the navigation. |
level | level | number | 1 | Heading level of the page title: 1 for a page, 2 or 3 when the shell sits inside one. |
nav | — | DashboardNavGroup[] | [] | Navigation groups, each with an optional label and its items. An item may hold one level of sub-items. |
open | open | boolean | true | Whether the sidebar is expanded on a wide screen. |
storageKey | storage-key | string | '' | Remembers the expanded or collapsed state in localStorage under this key. |
user | — | DashboardUser | undefined | — | The signed-in user, shown in the sidebar footer. |
variant | variant | SidebarVariant | 'sidebar' | How the sidebar sits beside the page: sidebar, floating or inset. |
Events
| Event | Description |
|---|---|
nana-toggle | Fired when the sidebar expands or collapses on a wide screen (detail.open) |
Slots
| Slot | Description |
|---|---|
(default) | The page content under the header |
mark | The brand's mark, in place of its first letter |
breadcrumb | A breadcrumb in the top bar, after the sidebar trigger |
search | The middle of the top bar, usually a search field |
toolbar | The end of the top bar, such as notifications and a theme toggle |
actions | The page's buttons, beside the title |
footer | The sidebar's footer, in place of the user card |
CSS parts
| Part | Description |
|---|---|
::part(layout) | The sidebar layout |
::part(sidebar) | The sidebar panel, exported from the layout |
::part(page) | The page beside the sidebar, exported from the layout |
::part(brand) | The brand at the top of the sidebar |
::part(user) | The user card in the sidebar footer |
::part(top-bar) | The top bar |
::part(header) | The page header |
::part(body) | The area holding the page header and the content |
NanaDashboardBrand
| Prop | Type |
|---|---|
namerequired | string |
href | string |
mark | Snippet |
NanaDashboardShell
| Prop | Type | Default |
|---|---|---|
brandrequired | string | |
brandHref | string | |
navrequired | DashboardNavGroup[] | |
user | DashboardUser | |
headingrequired | string | |
description | string | |
level | PageHeaderLevel | 1 |
variant | SidebarVariant | 'sidebar' |
collapsible | SidebarCollapsible | 'icon' |
openbind: | boolean | true |
storageKey | string | |
label | string | 'Main' |
mark | Snippet | |
breadcrumb | Snippet | |
search | Snippet | |
toolbar | Snippet | |
actions | Snippet | |
footer | Snippet | |
children | Snippet |
brand, nav and heading are required. user fills the sidebar footer. variant,
collapsible, open (bindable), storageKey and label pass to the sidebar layout;
description and level to the page header. brandHref links the brand.