Dashboard Layout
DashboardContainer lays out a dashboard page edge to edge: a header, section headers, a chart grid and tables, each bringing its own padding. Bordered blocks share their edges instead of doubling them.
@dentil/dashboard-layoutOn this page
Billing
Overview
- Free1,284
- Starter642
- Pro318
- Enterprise41
Invoices
'use client';
import { Plus } from 'lucide-react';
import { useState } from 'react';
import { CategoryBarChart } from '@/components/dentil/charts/category-bar-chart';
import { LineChart } from '@/components/dentil/charts/line-chart';
import {
DashboardContainer,
DashboardGrid,
DashboardHeader,
DashboardHeading,
DashboardSection,
DashboardSectionContent,
DashboardSectionHeader,
DashboardSubheading,
DashboardTableHeader,
} from '@/components/dentil/dashboard-layout/dashboard-layout';
import { DataTable } from '@/components/dentil/data-table/data-table';
import type { TableQuery } from '@/components/dentil/data-table/types';
import { Button } from '@/components/ui/button';
import { DEMO_NOW, DEMO_UPDATED_AT, revenue, revenueTotals, subscriptionsByPlan } from '@/lib/demo/charts';
import { invoiceColumns } from '@/lib/demo/columns';
import { useInvoices } from '@/lib/demo/invoices';
const currency = new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP' });
const formatPence = (pence: number) => currency.format(pence / 100);
export function DashboardLayoutOverviewDemo() {
const [query, setQuery] = useState<TableQuery>({});
const { data, hasMore, loading, fetching } = useInvoices(query);
return (
<DashboardContainer>
<DashboardHeader>
<DashboardHeading>Billing</DashboardHeading>
<Button size="sm">
<Plus />
Create invoice
</Button>
</DashboardHeader>
<DashboardSection>
<DashboardSectionHeader>
<DashboardSubheading>Overview</DashboardSubheading>
</DashboardSectionHeader>
<DashboardGrid>
<DashboardSectionContent>
<LineChart
title="Revenue"
value={revenueTotals.current}
previousValue={revenueTotals.previous}
formatValue={formatPence}
data={revenue}
series={[
{ key: 'value', label: 'This period' },
{ key: 'previous', label: 'Previous period', comparison: true, dateKey: 'previousDate' },
]}
unit="day"
now={DEMO_NOW}
timezone="Europe/London"
locale="en-GB"
updatedAt={DEMO_UPDATED_AT}
/>
</DashboardSectionContent>
<DashboardSectionContent>
<CategoryBarChart title="Subscriptions by plan" meta="Today" items={subscriptionsByPlan} locale="en-GB" />
</DashboardSectionContent>
</DashboardGrid>
</DashboardSection>
<DashboardTableHeader>
<DashboardSubheading>Invoices</DashboardSubheading>
<Button size="sm" variant="secondary">
Export
</Button>
</DashboardTableHeader>
<DataTable
columns={invoiceColumns}
data={data ?? []}
loading={loading}
fetching={fetching}
hasMore={hasMore}
query={query}
setQuery={setQuery}
showPagination
url={(invoice) => `#${invoice.id}`}
/>
</DashboardContainer>
);
}Installation
pnpm dlx shadcn@latest add @dentil/dashboard-layoutnpx shadcn@latest add @dentil/dashboard-layoutyarn dlx shadcn@latest add @dentil/dashboard-layoutbunx --bun shadcn@latest add @dentil/dashboard-layoutFiles land in components/dentil/dashboard-layout/. It has no shadcn dependencies and no client code, so it renders in a Server Component. asChild uses Radix Slot.
Usage
Put DashboardContainer straight inside your app shell's content area, with no padding. Headers and section bodies add 20px on each side, and tables run to the edge.
import {
DashboardContainer,
DashboardGrid,
DashboardHeader,
DashboardHeading,
DashboardSection,
DashboardSectionContent,
DashboardSectionHeader,
DashboardSubheading,
DashboardTableHeader,
} from '@/components/dentil/dashboard-layout/dashboard-layout';
<DashboardContainer>
<DashboardHeader>
<DashboardHeading asChild>
<h1>Billing</h1>
</DashboardHeading>
<Button>Create invoice</Button>
</DashboardHeader>
<DashboardSection>
<DashboardSectionHeader>
<DashboardSubheading>Overview</DashboardSubheading>
</DashboardSectionHeader>
<DashboardGrid>
<DashboardSectionContent>
<LineChart title="Revenue" … />
</DashboardSectionContent>
<DashboardSectionContent>
<CategoryBarChart title="Subscriptions by plan" … />
</DashboardSectionContent>
</DashboardGrid>
</DashboardSection>
<DashboardTableHeader>
<DashboardSubheading>Invoices</DashboardSubheading>
</DashboardTableHeader>
<DataTable … />
</DashboardContainer>Borders
The blocks draw no outer border. Each child of DashboardContainer, DashboardSplit and its panes is pulled up and left by 1px, so a table's top border, a split's top border and the sidebar's left border land on the line before them instead of beside it. The container's -1px margin does the same against your shell, so a bordered child sits on the shell's edge.
Examples
Split
A record page: the main pane holds tables, and the sidebar holds details. They sit side by side from xl.
Ada Lovelace
Invoices
Details
- Currency
- GBP
- Balance
- £0.00
Notes
Pays by bank transfer on the first of the month.
'use client';
import { useState } from 'react';
import {
DashboardContainer,
DashboardHeader,
DashboardHeading,
DashboardSection,
DashboardSectionContent,
DashboardSectionHeader,
DashboardSectionTitle,
DashboardSplit,
DashboardSplitMain,
DashboardSplitSidebar,
DashboardSubheading,
DashboardTableHeader,
} from '@/components/dentil/dashboard-layout/dashboard-layout';
import { Descriptions } from '@/components/dentil/description-list/description-list';
import { DataTable } from '@/components/dentil/data-table/data-table';
import type { TableQuery } from '@/components/dentil/data-table/types';
import { Button } from '@/components/ui/button';
import { invoiceColumns } from '@/lib/demo/columns';
import { useInvoices } from '@/lib/demo/invoices';
export function DashboardLayoutSplitDemo() {
const [query, setQuery] = useState<TableQuery>({});
const { data, hasMore, loading, fetching } = useInvoices(query);
return (
<DashboardContainer>
<DashboardHeader>
<DashboardHeading>Ada Lovelace</DashboardHeading>
<Button size="sm" variant="secondary">
Edit customer
</Button>
</DashboardHeader>
<DashboardSplit className="border-t">
<DashboardSplitMain>
<DashboardTableHeader>
<DashboardSubheading>Invoices</DashboardSubheading>
</DashboardTableHeader>
<DataTable
columns={invoiceColumns}
data={data ?? []}
loading={loading}
fetching={fetching}
hasMore={hasMore}
query={query}
setQuery={setQuery}
showPagination
url={(invoice) => `#${invoice.id}`}
/>
</DashboardSplitMain>
<DashboardSplitSidebar>
<DashboardSection>
<DashboardSectionHeader>
<DashboardSubheading>Details</DashboardSubheading>
</DashboardSectionHeader>
<DashboardSectionContent>
<Descriptions
orientation="vertical"
items={[
{ term: 'Email', detail: '[email protected]', copy: '[email protected]' },
{ term: 'Currency', detail: 'GBP' },
{ term: 'Balance', detail: '£0.00' },
]}
/>
</DashboardSectionContent>
<DashboardSectionContent>
<DashboardSectionTitle>Notes</DashboardSectionTitle>
<p className="text-muted-foreground text-sm">Pays by bank transfer on the first of the month.</p>
</DashboardSectionContent>
</DashboardSection>
</DashboardSplitSidebar>
</DashboardSplit>
</DashboardContainer>
);
}Give the container fixedHeight and a parent with a height, and each pane scrolls on its own.
<DashboardContainer fixedHeight>
<DashboardHeader>
<DashboardHeading>Ada Lovelace</DashboardHeading>
</DashboardHeader>
<DashboardSplit className="border-t">
<DashboardSplitMain>…</DashboardSplitMain>
<DashboardSplitSidebar>…</DashboardSplitSidebar>
</DashboardSplit>
</DashboardContainer>API reference
DashboardContainer
| Prop | Type | Default | Description |
|---|---|---|---|
| fixedHeight | boolean | false | Fills the parent's height instead of growing with the content. Use it with DashboardSplit so the main pane and sidebar scroll on their own. The parent needs a height. |
| className | string | — | Merged onto the container. |
| …props | ComponentProps<'div'> | — | Other div props. |
DashboardHeading and DashboardSubheading
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Renders the styles on the child, so you can pick the heading level, e.g. <DashboardHeading asChild><h1>Billing</h1></DashboardHeading>. |
| className | string | — | Merged onto the heading. |
Parts
Every part takes className and the props of the element it renders, and sets a data-slot.
| Prop | Type | Default | Description |
|---|---|---|---|
| DashboardHeader | div | — | Page title row: heading on the left, actions on the right. Stacks below sm. 20px side padding. |
| DashboardHeading | h3 | — | Page title, 18px bold. |
| DashboardSubheading | h4 | — | Section title for a section or table header, 16px bold. |
| DashboardGrid | div | — | One column, then two from xl. Rows size to their content. |
| DashboardSplit | div | — | Main pane and sidebar, stacked until xl, then side by side. Pulls its panes together by 1px. |
| DashboardSplitMain | div | — | The wide pane. Scrolls when the split has a height. |
| DashboardSplitSidebar | div | — | Full width when stacked, 384px from xl, with a left border. Scrolls when the split has a height. |
| DashboardSection | section | — | Groups a section header with its content. No styles. |
| DashboardSectionHeader | div | — | Title row with a bottom border and 16px above it, 62px tall. |
| DashboardSectionContent | div | — | Padded body: 20px sides, 16px top and bottom. |
| DashboardSectionTitle | p | — | Small 14px label above a block in a section body. |
| DashboardTableHeader | div | — | Title row above a table, 61px tall, with no bottom border so the table's top border closes it. Its 16px top margin is !important, so it clears the block above even as a direct child of the container. |