Layout
Examples of how to build effective page layouts on the Unkey dashboard.
Basics
A simple page with a header and actions.
import {
Button,
PageBody,
PageContainer,
PageHeader,
PageHeaderActions,
PageHeaderContent,
PageHeaderDescription,
PageHeaderTitle,
} from "@unkey/ui";
export default function BasicLayout() {
return (
<PageContainer>
<PageHeader>
<PageHeaderContent>
<PageHeaderTitle>General</PageHeaderTitle>
<PageHeaderDescription>Manage your workspace settings.</PageHeaderDescription>
</PageHeaderContent>
<PageHeaderActions>
<Button variant="outline">Copy ID</Button>
</PageHeaderActions>
</PageHeader>
<PageBody>
<div className="mt-4 flex h-44 w-full items-center justify-center rounded-lg bg-grayA-3 font-mono text-gray-11 text-xs">
Your content here
</div>
</PageBody>
</PageContainer>
);
}
Secondary navigation
Use a secondary navigation when pages have sections nested one level deep within them.
import {
PageBody,
PageContainer,
PageHeader,
PageHeaderContent,
PageHeaderTitle,
SecondaryNav,
SecondaryNavGroup,
SecondaryNavItem,
SecondaryNavTitle,
} from "@unkey/ui";
export default function SecondaryNavLayout() {
return (
<div className="flex w-full flex-1 flex-col md:flex-row">
<SecondaryNav aria-label="Settings" className="md:w-56">
<SecondaryNavTitle>Settings</SecondaryNavTitle>
<SecondaryNavGroup>
<SecondaryNavItem href="#general" active>
General
</SecondaryNavItem>
<SecondaryNavItem href="#team">Team</SecondaryNavItem>
</SecondaryNavGroup>
</SecondaryNav>
<div className="min-w-0 flex-1">
<PageContainer>
<PageHeader>
<PageHeaderContent>
<PageHeaderTitle>General</PageHeaderTitle>
</PageHeaderContent>
</PageHeader>
<PageBody>
<div className="mt-4 flex h-48 w-full items-center justify-center rounded-lg bg-grayA-3 font-mono text-gray-11 text-xs">
Your content here
</div>
</PageBody>
</PageContainer>
</div>
</div>
);
}
Add the rail in the section layout, then let each page render its own PageBody.
Back link
Detail pages put a PageHeaderBack link above the title. It points to the parent list.
import {
Button,
PageBody,
PageContainer,
PageHeader,
PageHeaderActions,
PageHeaderBack,
PageHeaderContent,
PageHeaderTitle,
} from "@unkey/ui";
export default function LayoutWithBackLink() {
return (
<PageContainer>
<PageHeader>
<PageHeaderContent>
<PageHeaderBack href="#">Log Drains</PageHeaderBack>
<PageHeaderTitle>Acme production logs</PageHeaderTitle>
</PageHeaderContent>
<PageHeaderActions>
<Button variant="outline">Edit</Button>
</PageHeaderActions>
</PageHeader>
<PageBody>
<div className="mt-4 flex h-44 w-full items-center justify-center rounded-lg bg-grayA-3 font-mono text-gray-11 text-xs">
Your content here
</div>
</PageBody>
</PageContainer>
);
}
In the dashboard, pass a Next.js link with render={<Link href={listHref} />} so the navigation stays client-side.
Full width
For full width pages like logs, requests, use the full width prop to let your page span the entire width of the viewport. Every page scrolls with the document, full width pages included. A DataTable grows with its rows.
import {
Button,
PageBody,
PageContainer,
PageHeader,
PageHeaderActions,
PageHeaderContent,
PageHeaderDescription,
PageHeaderTitle,
} from "@unkey/ui";
export default function FullWidthLayout() {
return (
<PageContainer width="full">
<PageHeader>
<PageHeaderContent>
<PageHeaderTitle>Logs</PageHeaderTitle>
<PageHeaderDescription>Requests across your workspace.</PageHeaderDescription>
</PageHeaderContent>
<PageHeaderActions>
<Button variant="outline">Refresh</Button>
</PageHeaderActions>
</PageHeader>
<PageBody>
<div className="flex h-52 w-full items-center justify-center bg-grayA-3 font-mono text-gray-11 text-xs">
Your content here
</div>
</PageBody>
</PageContainer>
);
}
Pinned chrome
On a full width page, the page chrome pins under the top nav while the rows scroll. These slots pin, from top to bottom:
PageHeaderControlsContainer(the filter and time controls)ControlCloud(the active filter chips, only when filters are set)- The compact 50px logs chart
- The table column header
A slot that is not on the page takes no space. The chips appear and go away, and the slots below move with them.
The header, controls, chips and chart pin when the window is at least 48rem wide and 40rem tall. Below that size they scroll with the page. The column header pins from md up at any height, but only while the table fits its box. A table wider than its box scrolls sideways instead, and its column header then scrolls with the page.
Pinning applies only inside a full width page. On other pages, and in dialogs and sheets, the same components render as normal blocks.
The overview charts (API, ratelimit, key and identity overviews) also use the chart slot, so the whole chart stays in view while rows scroll under it.
To pin a new piece of chrome, wrap it in StickySlot with its slot name:
<StickySlot slot="chart" className="w-full">
...
</StickySlot>
Pass render to pin an element other than a div, and enabled={false} to take the slot out of the stack:
<StickySlot slot="columns" enabled={headerPinned} render={<thead />} />
The slot order is fixed in sticky-stack.ts. Render slots in that order, with no other content between them. In development, a slot that is out of place at scroll position 0 logs a warning. The check does not run after the page scrolls, so it can miss some order errors.