08/Structure
Dashboard layout
Fixed sidebar, topbar and content area. On mobile the sidebar becomes a side panel.
Structure
See the full template in examples/dashboard.html.
Q 48kVentas del mes
312Pedidos
HTML
<div class="cb-dash">
<aside class="cb-dash__sidebar" id="sidebar" data-cb-dash-sidebar aria-label="Menú del panel">
<a href="#" class="cb-logo cb-dash__brand">...</a>
<nav class="cb-dash__nav">
<div class="cb-dash__group">
<p class="cb-dash__group-title">General</p>
<a class="cb-dash__link" href="#" aria-current="page">Resumen</a>
</div>
</nav>
</aside>
<div class="cb-dash__scrim" data-cb-dash-scrim="sidebar"></div>
<div class="cb-dash__main">
<header class="cb-dash__topbar">
<button class="cb-icon-btn cb-dash__toggle" type="button" data-cb-dash-toggle="sidebar" aria-label="Menú">...</button>
<div class="cb-dash__topbar-actions">...</div>
</header>
<main class="cb-dash__content">...</main>
</div>
</div>
Classes and modifiers
| Class | Description |
|---|---|
.cb-dash | Sidebar + content grid. The width is changed with --cb-dash-sidebar. |
.cb-dash__sidebar | Fixed column. Below 960px it is an off-screen panel. |
.cb-dash__scrim | Dark backdrop behind the sidebar on mobile. |
.cb-dash__link | Link with an icon; aria-current="page" marks the accent line. |
.cb-dash__topbar | Fixed top bar of the content. |
.cb-dash__toggle | Button visible only on mobile. |
.cb-dash__content, .cb-dash__header, .cb-dash__title | Main area and its header. |
.cb-panel, .cb-panel__head, .cb-panel__body | Bordered box to group content. |
data-cb-* attributes
| Attribute | Description |
|---|---|
data-cb-dash-sidebar | Marks the sidebar. Needs an id. |
data-cb-dash-toggle="id" | Button that opens it on mobile. |
data-cb-dash-scrim="id" | Backdrop that closes it on click. |
JavaScript
| Event | When it fires |
|---|---|
cb:open / cb:close | On the sidebar when it opens or closes on mobile. |
Accessibility
- On mobile the sidebar traps focus and closes with Esc.
- Use
mainfor the content andaria-labelon the sidebar.