Playground

Dashboard shell block

App frame with sidebar, top bar and content that collapses to a drawer on small screens.

  • 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

PropTypeDefaultDescription
brandReactNode–Your logo or name, shown above the navigation.
renderLinkRenderLink–Renders each navigation link, so a client router can handle the click. Default a plain `<a href>`.
nav requiredShellNavItem[]–The navigation links shown in the sidebar and in the small-screen drawer.
navLabelstring'Main'Names the navigation landmark. Default "Main".
topbarReactNode–Right side of the top bar: search, account menu.
menuLabelstring'Menu'Text of the button that opens the navigation drawer on small screens. Default "Menu".
children requiredReactNode–The page: put its h1 inside.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[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

ClassStylesheet
.divider09-links.css
.link09-links.css
.skip-link09-links.css
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css
.btnicon-button.css
.btn-iconicon-button.css
.btn-smicon-button.css
.tooltiptooltip.css
.commanddialog.css
.dialog-closedialog.css
.dialog-contentdialog.css
.dialog-descriptiondialog.css
.dialog-footerdialog.css
.dialog-headerdialog.css
.dialog-overlaydialog.css
.dialog-titledialog.css
.drawer-contentdialog.css
.drawer-contentdrawer.css
.sidebarsidebar.css
.sidebar-contentsidebar.css
.sidebar-drawersidebar.css
.sidebar-footersidebar.css
.sidebar-groupsidebar.css
.sidebar-group-labelsidebar.css
.sidebar-headersidebar.css
.sidebar-iconsidebar.css
.sidebar-innersidebar.css
.sidebar-itemsidebar.css
.sidebar-labelsidebar.css
.sidebar-listsidebar.css
.sidebar-togglesidebar.css
.sidebar-triggersidebar.css
.navbarnavbar.css
.navbar-actionsnavbar.css
.navbar-brandnavbar.css
.navbar-drawernavbar.css
.navbar-linknavbar.css
.navbar-linksnavbar.css
.navbar-listnavbar.css
.navbar-menunavbar.css
.app-shellapp-shell.css
.app-shell-asideapp-shell.css
.app-shell-mainapp-shell.css
.app-shell-navbarapp-shell.css
.sidebarapp-shell.css
.sidebar-innerapp-shell.css
.skip-linkapp-shell.css
.block-shellblock-dashboard-shell.css
.block-shell-brandblock-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.

app.css
.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

KeysAction
EscapeCloses it and focus returns to the button