Dashboard shell block
App frame with sidebar, top bar and content that collapses to a drawer on small screens.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsbeta
- Built on native elements
- The sidebar and the drawer hold the same navigation landmark, named by navLabel; the current page has aria-current="page".
- Below 800px the sidebar is hidden and a Menu button opens a left drawer: focus is trapped, Escape closes it and focus returns to the button.
- Choosing a link closes the drawer. The content is a main landmark; put one h1 in it.
- Styles in one file:
09-links.css
Import
import '@monoline/css';
import {BlockDashboardShell} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add block-dashboard-shell
Usage
import {Badge, BlockDashboardShell, Heading, Text} from '@monoline/react';
<BlockDashboardShell
brand="Your app"
nav={[{label: 'Overview', href: '#', current: true}, {label: 'Reports', href: '#'}, {label: 'Customers', href: '#'}, {label: 'Settings', href: '#'}]}
topbar={<Badge>Ada Example</Badge>}
>
<Heading level={1} size="xl">Overview</Heading>
<Text tone="muted">Your content goes here.</Text>
</BlockDashboardShell>
Examples
Sidebar, top bar and content
Narrow the window: the sidebar becomes a Menu button and a drawer.
With a client router
renderLink receives each link's props. Return your router's link: React Router `({href, ...p}) => <NavLink to={href} {...p} />`, Next.js `(p) => <NextLink {...p} />`. The demo uses a plain anchor to show the shape.
Props
BlockDashboardShellProps
| Prop | Type | Default | Description |
|---|---|---|---|
brand | ReactNode | – | Your logo or name, shown above the navigation. |
renderLink | RenderLink | – | Renders each navigation link, so a client router can handle the click. Default a plain `<a href>`. |
nav required | ShellNavItem[] | – | The navigation links shown in the sidebar and in the small-screen drawer. |
navLabel | string | 'Main' | Names the navigation landmark. Default "Main". |
topbar | ReactNode | – | Right side of the top bar: search, account menu. |
menuLabel | string | 'Menu' | Text of the button that opens the navigation drawer on small screens. Default "Menu". |
children required | ReactNode | – | The page: put its h1 inside. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[data-side="bottom"] | drawer.css |
[data-side="end"] | drawer.css |
[data-side="left"] | drawer.css |
[data-side="right"] | drawer.css |
[data-side="start"] | drawer.css |
[data-side="top"] | drawer.css |
[aria-current="page"] | sidebar.css |
[data-collapsed] | sidebar.css |
[aria-current="page"] | navbar.css |
[data-sticky] | navbar.css |
[data-scroll="contained"] | app-shell.css |
CSS classes
| Class | Stylesheet |
|---|---|
.divider | 09-links.css |
.link | 09-links.css |
.skip-link | 09-links.css |
.btn | 02-buttons.css |
.btn-block | 02-buttons.css |
.btn-danger | 02-buttons.css |
.btn-ghost | 02-buttons.css |
.btn-lg | 02-buttons.css |
.btn-line | 02-buttons.css |
.btn-sm | 02-buttons.css |
.btn-solid | 02-buttons.css |
.btn | icon-button.css |
.btn-icon | icon-button.css |
.btn-sm | icon-button.css |
.tooltip | tooltip.css |
.command | dialog.css |
.dialog-close | dialog.css |
.dialog-content | dialog.css |
.dialog-description | dialog.css |
.dialog-footer | dialog.css |
.dialog-header | dialog.css |
.dialog-overlay | dialog.css |
.dialog-title | dialog.css |
.drawer-content | dialog.css |
.drawer-content | drawer.css |
.sidebar | sidebar.css |
.sidebar-content | sidebar.css |
.sidebar-drawer | sidebar.css |
.sidebar-footer | sidebar.css |
.sidebar-group | sidebar.css |
.sidebar-group-label | sidebar.css |
.sidebar-header | sidebar.css |
.sidebar-icon | sidebar.css |
.sidebar-inner | sidebar.css |
.sidebar-item | sidebar.css |
.sidebar-label | sidebar.css |
.sidebar-list | sidebar.css |
.sidebar-toggle | sidebar.css |
.sidebar-trigger | sidebar.css |
.navbar | navbar.css |
.navbar-actions | navbar.css |
.navbar-brand | navbar.css |
.navbar-drawer | navbar.css |
.navbar-link | navbar.css |
.navbar-links | navbar.css |
.navbar-list | navbar.css |
.navbar-menu | navbar.css |
.app-shell | app-shell.css |
.app-shell-aside | app-shell.css |
.app-shell-main | app-shell.css |
.app-shell-navbar | app-shell.css |
.sidebar | app-shell.css |
.sidebar-inner | app-shell.css |
.skip-link | app-shell.css |
.block-shell | block-dashboard-shell.css |
.block-shell-brand | block-dashboard-shell.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
.divider {
border-color: var(--accent);
}
.divider[data-side="bottom"] {
background: var(--wash);
}
Accessibility
- The sidebar and the drawer hold the same navigation landmark, named by navLabel; the current page has aria-current="page".
- Below 800px the sidebar is hidden and a Menu button opens a left drawer: focus is trapped, Escape closes it and focus returns to the button.
- Choosing a link closes the drawer. The content is a main landmark; put one h1 in it.
- With renderLink the links are rendered by your router link; the block still sets the class and aria-current="page" on it.
Keyboard
| Keys | Action |
|---|---|
| Escape | Closes it and focus returns to the button |