Admin Panel (Dashboard)

A complete skeleton for CRM, ERP and B2B panels - a sidebar layout, navigation with an expandable tree, and a "Faux Cutout" header. Requires a separate molique-style-admin.css file - this page (like every documentation page) is itself a live example of it. The full layout is in the examples.

1. Layout structure

Three classes split the screen into a sidebar and content. .admin-layout is a two-column CSS Grid - a variable controls the sidebar width, so the size variants (below) don't need separate grid rules.

<div class="admin-layout">
  <aside class="admin-sidebar">
    <a href="#" class="admin-brand admin-logo-compact">Logo</a>
    <ul class="admin-nav">
      <li><a href="#" class="admin-nav-link is-active">Dashboard</a></li>
      <li><a href="#" class="admin-nav-link">Clients</a></li>
    </ul>
  </aside>

  <!-- Optional second column, no background (see .admin-rail below) -->
  <div class="admin-rail"><!-- filters, sub-nav, a list --></div>

  <main class="admin-main">
    <!-- Panel content -->
  </main>
</div>
Class What it does
.admin-layout A two-column grid. Below 768px the columns disappear - the sidebar becomes a horizontal bar at the bottom of the screen (Bottom Nav), and .admin-main takes up the full width.
.admin-sidebar position: sticky on desktop, position: fixed (bottom of the screen) on mobile. The background is always dark, regardless of light/dark theme - see pitfall #1.
--admin-main-padding The inner padding of .admin-main, 32 px by default. Up to 768 px --admin-main-padding-mobile applies, 12 px by default. Set it on :root. The bottom padding stays larger because the mobile navigation bar sits over it.
.admin-rail An optional SECOND column between the sidebar and the content: sub-navigation, filters, a list of records. Deliberately without a background - it sits on --bg-body, so in floating mode it reads as the ground between two cards rather than a third card. The grid track is added by a :has() rule only once the element exists: an empty track would generate a second gap in floating mode and shift the layout of every page without a rail. It sticks like the sidebar. Width: --admin-rail-width (240px). On mobile the grid collapses to one column anyway, so the rail stacks ABOVE the content - it is not hidden, because silently losing content is undiagnosable.
.admin-rail-hide-mobile Opt-in: drops the rail below 768px. For rails that merely duplicate navigation available elsewhere - not for ones carrying content of their own.
.admin-main The content column. overflow-x: hidden - wide tables need their own .table-wrapper.
.admin-brand The sidebar logo - fits an image, SVG, or text, and never breaks the width.
.sidebar-md / .sidebar-sm On .admin-layout. They narrow the sidebar: -md = icon above a small caption, -sm = icons only. Usually applied by the toggle's JS (section 2), but they also work as a fixed class in the markup.
.admin-layout-floating Pulls the sidebar and content away from the window edges and rounds both corners. On mobile the gap disappears automatically.
.admin-logo-hide / .admin-logo-compact Logo behavior in -md/-sm and on mobile: hide it entirely or collapse it to a 32×32px square badge.
.admin-logo-swap The third logo strategy: swap it for a different file. Two images inside .admin-brand - .admin-logo-full (wordmark, wide sidebar) and .admin-logo-mark (logomark, -md/-sm and mobile). A wordmark scaled down to 32px is unreadable, and a logomark is a separate asset, not a smaller rendering of the same one.
.fade-bottom Opt-in on .admin-sidebar or .admin-main - a fade gradient at the bottom of the scrollable area instead of a hard cutoff. The full variable list is in the variable reference.

The second column (.admin-rail)

An optional column between the sidebar and the content - for sub-navigation, filters or a list of records. It has no background of its own, so in floating mode it reads as the ground between two cards rather than a third card. The preview is squeezed to the height of the box; in production both side columns are screen-tall and stick while the page scrolls.

Filters All Active Finished
Content
<div class="admin-layout admin-layout-floating">
  <aside class="admin-sidebar">…</aside>

  <!-- No background: it sits on --bg-body -->
  <div class="admin-rail">
    <span class="fw-semibold">Filters</span>
    …
  </div>

  <main class="admin-main">…</main>
</div>
<!-- Wordmark in the wide sidebar, logomark in -md/-sm and on mobile -->
<a href="#" class="admin-brand admin-logo-swap">
  <img class="admin-logo-full" src="img/logo.svg" alt="Company name">
  <img class="admin-logo-mark" src="img/logomark.svg" alt="">
</a>

Controlled by variables, not just classes

The sidebar's colors (--sidebar-bg, --sidebar-text…), the floating variant's radii, and the height of the .fade-bottom gradient are all CSS variables - a full description of each is in the variable reference, in the "Admin panel" and "Admin panel sidebar" sections.

2. Sidebar width toggle

A single button cyclically toggles the sidebar through three widths: full → .sidebar-md → .sidebar-sm → back to full. The hamburger icon morphs into an arrow in step with the changes, and the choice is remembered in localStorage between visits.

The logic lives in the core, not the autoloader

Unlike most interactive components, handling #molique-sidebar-toggle isn't a separate, lazily loaded module - it lives permanently in molique-script.js. Just add a button with the right ID to the markup, no registration needed.

<!-- Usually at the bottom of .admin-nav, in a separate block pinned to the bottom -->
<ul class="admin-nav admin-nav-bottom">
  <li>
    <button type="button" id="molique-sidebar-toggle" class="admin-nav-link">
      <span class="sidebar-toggle-icon">
        <span></span><span></span><span></span>
      </span>
      <span class="nav-text">Collapse panel</span>
    </button>
  </li>
</ul>
Class / attribute What it does
#molique-sidebar-toggle An ID, not a class - molique-script.js looks for it with a getElementById-style querySelector. It must be exactly this identifier and appear only once on the page.
.sidebar-toggle-icon Requires exactly three empty <span>s inside - CSS positions them via :nth-child to produce three different shapes (hamburger / asymmetric lines / arrow).

Anti-FOUC: the script in <head> is mandatory

The width choice is saved to localStorage, but molique-script.js only reads it on DOMContentLoaded - that is, AFTER the first render. Without an extra step, a returning user with a collapsed sidebar would see it full-width first, then narrow a moment later. The fix: a small, synchronous script (no defer/async) right at the top of <head>, which reads localStorage and applies the sidebar-md/sidebar-sm class directly to <html> before the browser draws anything - the same mechanism also sets data-theme for the light/dark theme. In this project the script lives in partials/head.html and reaches every page automatically; in a new deployment you must copy it by hand along with the mirrored CSS rules (:root.sidebar-md / :root.sidebar-sm in _admin-layout.scss) - without them, saving to localStorage alone does nothing.

3. Navigation - links

A flat list of links. On desktop a column, below 768px a horizontal bar (Bottom Nav) - the same markup, zero conditionals in the HTML.

Class What it does
.admin-nav On a <ul>. A column on desktop, a horizontal bar on mobile.
.admin-nav-link On an <a> (or <button> for an action, as in section 2). The .nav-text child is optional, but required if you want the caption to hide in .sidebar-sm.
.admin-nav-link.is-active The current item - --primary background. Set it manually or hook up molique-admin-nav-active.js (below).
.admin-nav-divider A horizontal line separating groups of links. Disappears on mobile.
.admin-nav-bottom On a separate <ul class="admin-nav"> - margin-top: auto pins it to the very bottom of the sidebar (e.g. a "Settings" link or the toggle from section 2). Hidden on mobile.
.mobile-only-nav-item An item visible ONLY in Bottom Nav - a duplicated link outside the five main icons (see section 5).

Active item from the URL

A sidebar with no submenu (like the one on the left of this page) can use the js/modules/molique-admin-nav-active.js module instead of a manual .is-active (auto-loaded whenever .admin-nav is present) - it applies the class to whichever .admin-nav-link matches the current URL, including its duplicate in the mobile bar. Don't hard-code the active state into a shared partial - the sidebar is often one file shared by many pages.

4. Submenu - tree / drill-down

An expandable group of links built on native <details>. The same markup renders three different ways depending on the sidebar width - no variants needed in the HTML.

Context Behavior
Full sidebar (no modifier) A classic tree - the list slides out below the item, pushing the rest of the sidebar down.
.sidebar-md / .sidebar-sm Drill-down: the submenu covers the ENTIRE sidebar (below the logo), and the <summary> turns into a "Back" bar.
Mobile (Bottom Nav, <768px) The same drill-down, but as a full-screen overlay sliding in from the bottom.
<details class="admin-nav-submenu">
  <summary class="admin-nav-link">
    <span class="nav-text">Finance</span>
  </summary>
  <div class="admin-nav-submenu-list">
    <a href="#" class="admin-nav-submenu-link">Invoices</a>
    <a href="#" class="admin-nav-submenu-link is-active">Payments</a>
  </div>
</details>
<!-- Starting state: NO open attribute, see pitfall #3 -->
<details class="admin-nav-submenu">…</details>
Class What it does
.admin-nav-submenu On a <details>. The native mechanism handles opening - CSS and JS only attach the visual style and animations.
.admin-nav-submenu-list A direct child of <details>, alongside <summary> - don't nest it deeper, the rules target :scope >.
.admin-nav-submenu-link A single link inside the submenu. .is-active variant works the same as on top-level links.

JS module: molique-admin-nav.js

Auto-loaded whenever .admin-nav-submenu is present. It highlights the active branch from the URL, on mobile it prevents that branch from auto-expanding on page load, it animates the drill-down's exit (the native <details> hides its content instantly, so the module adds an .is-closing class for the duration of the animation and only removes open once it's finished), it closes on Esc, and - on mobile devices only - opening one submenu closes the others.

5. Mobile: Bottom Nav and "More"

Below 768px the sidebar disappears and .admin-nav becomes a horizontal bar of icons at the bottom of the screen. When there are more items than fit in the bar, the overflow hides behind a separate "More" button - a checkbox hack, not <details>, so it doesn't collide with the submenu from section 4.

<input type="checkbox" id="more-toggle" class="mobile-more-toggle">
<label for="more-toggle" class="admin-nav-link mobile-more-label">
  <span class="nav-text">More</span>
</label>

<div class="admin-nav-dropdown-menu">
  <a href="#" class="admin-nav-link">Settings</a>
  <a href="#" class="admin-nav-link">Log out</a>
</div>
Class What it does
.mobile-more-toggle A hidden checkbox - the browser holds the state, zero JS.
.mobile-more-label A <label for="…"> pointing to the checkbox. Visible EXCLUSIVELY on mobile - it hides on desktop.
.admin-nav-dropdown-menu On desktop: display: contents - the links inside behave as if they sat directly in .admin-nav. On mobile: a drawer sliding up from the bottom once the checkbox is checked.

6. Faux Cutout header

A page header with the illusion of a cutout around the actions block - the effect is achieved with two radial-gradient corners, no SVG and no masks. A full, live example is on the Admin Layout page.

<div class="dashboard-header">
  <div>
    <h1>Welcome, Anna!</h1>
    <p>Here's a summary of your day.</p>
  </div>
  <div class="dashboard-header-actions">
    <button class="btn-primary">New order</button>
  </div>
</div>
Class What it does
.dashboard-header A row: title on the left, actions block on the right. On mobile: a column, the cutout disappears.
.dashboard-header-actions A block with an apparent cutout in the top-left and bottom-right corners. The cutout's color is the --cutout-bg variable - see pitfall #4.

7. Sortable List

Reorder items via two equal, parallel paths at once: dragging a handle (mouse/touch/pen, via Pointer Events - not native HTML5 Drag&Drop, which doesn't work on touch) and up/down buttons, the only path for keyboard and screen-reader users. Zero JS config - data-sortable on the container is enough, js/modules/molique-sortable.js loads itself.

  • Home
  • About
  • Services
  • Contact

Item content is anything - plain text like above, or (recommended for denser admin lists) wrapped .data-row-compact with an icon and details:

<ul class="sortable-list" data-sortable>
  <li class="sortable-item">
    <button class="sortable-handle" aria-label="Drag to reorder">
      <svg class="icon" aria-hidden="true"><use href="img/icons-sprite.svg#ph-dots-six-vertical"></use></svg>
    </button>
    <div class="sortable-content">
      <div class="data-row-compact">
        <div class="row-content">
          <div class="row-title">Newsletter</div>
          <div class="row-details">Sent every Monday</div>
        </div>
      </div>
    </div>
    <div class="sortable-controls btn-action-group">
      <button class="btn-action" data-sortable-up aria-label="Move up">
        <svg class="icon" aria-hidden="true"><use href="img/icons-sprite.svg#ph-arrow-up"></use></svg>
      </button>
      <button class="btn-action" data-sortable-down aria-label="Move down">
        <svg class="icon" aria-hidden="true"><use href="img/icons-sprite.svg#ph-arrow-down"></use></svg>
      </button>
    </div>
  </li>
  <!-- more .sortable-item -->
</ul>

<script>
  // Persisting the new order to a backend - your app's job, not molique's
  document.querySelector('[data-sortable]').addEventListener('sortable:update', (e) => {
    console.log(e.detail.order); // data-sortable-id values in the new order
  });
</script>
Class / attribute What it does
data-sortable On the container (<ul>, <div>...) - enables the module. Every direct child with the class .sortable-item counts as an item.
.sortable-item A single item. Optional data-sortable-id="..." - lands in event.detail.order after a change.
.sortable-handle The drag handle. Always with an aria-label - also responds to the up/down arrow keys while focused.
.sortable-content Any item content - text, a badge, .data-row-compact.
.sortable-controls data-sortable-up data-sortable-down The up/down button pair (reuses .btn-action). The first/last item automatically gets disabled on the relevant button.

The sortable:update event

After EVERY change (drag, button, or the arrow keys on the handle) the container emits CustomEvent('sortable:update', { detail: { order, items } }). Molique has no backend of its own (the same way the carousel or lightbox make no requests) - persisting the new order is your app's job, listening for this event. The change is also announced through a hidden aria-live="polite" region for screen readers.

8. Pitfalls

1 The sidebar doesn't invert in dark mode

--sidebar-bg, --sidebar-text and --sidebar-highlight-rgb have a single, fixed value - the sidebar is always dark, regardless of the page's theme. This is deliberate (contrast with light content), but it means you can't lighten it via the light/dark toggle - only by overriding these variables directly.

2 Two #molique-sidebar-toggle elements on the page

The script takes the first element with this ID via querySelector. A second button with the same ID (invalid HTML, but the browser will still render it) ends up dead - nothing happens when it's clicked.

3 A submenu with a hard-coded open attribute in the markup

On desktop with a full sidebar it's just an expanded tree - harmless. But molique-admin-nav.js deliberately closes such an <details open> on startup if you happen to be on the mobile view: without that, visiting any subpage would open a full-screen drill-down instead of the content. Don't set open manually to mark "this is the active section" - that's what .is-active on the <summary> is for, not the open attribute.

4 --cutout-bg mismatched with the background behind the header

The cutout in .dashboard-header-actions is a gradient from the --cutout-bg color to transparent - if it doesn't match the actual background underneath exactly (e.g. in the .admin-layout-floating variant, where the content background is --bg-surface, not --bg-body), you'll see a square smudge in the corner instead of an invisible cutout.

5 Funnels (.chart-funnel) also need this bundle

Even though it's a chart component, .chart-funnel, .chart-pipeline and .chart-funnel-true physically live in molique-style-admin.css, not in the core - the rest of the charts (.chart-sparkline, .chart-radial…) work without this file, funnels don't. The full funnel reference is in the charts documentation.

6 You only copy the toggle button and the sidebar "jumps" on reload

#molique-sidebar-toggle saves its state to localStorage, but on its own it doesn't prevent flicker - that's the job of the synchronous inline script in <head> described in section 2 above. If you deploy the sidebar outside this project (without partials/head.html) and forget to move that script along with the mirrored :root.sidebar-md/:root.sidebar-sm rules in _admin-layout.scss, a returning user will see the full sidebar for a split second before it collapses to its remembered width.

9. Related pages