This document describes how to use and customize the Clearmin Bootstrap template. For topics not covered by this document, please refer to the official Bootstrap 5.3 documentation on getbootstrap.com.
| Version | 2.0 |
| Type | HTML Template |
| Bootstrap | 5.3.x (Sass sources + bootstrap.min.js / popper.min.js) |
| Layouts |
Responsive Fluid |
| Browsers | Latest Chrome, Edge, Firefox, Safari and their mobile versions |
| Dependencies | None: jQuery is no longer required |
| Uses Sass | Yes |
To start using Clearmin in a new project you can use this minimal template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="dist/css/clearmin.min.css">
<link rel="stylesheet" href="dist/css/roboto.css">
<link rel="stylesheet" href="dist/css/small-n-flat.css">
<link rel="stylesheet" href="dist/fontawesome/css/all.min.css">
<title>Clearmin Page</title>
</head>
<body class="cm-no-transition cm-1-navbar">
<div id="cm-menu">
<nav class="cm-navbar cm-navbar-primary">
<div class="cm-flex"><div class="cm-logo"></div></div>
<button type="button" class="btn btn-primary" data-toggle="cm-menu" aria-label="Toggle menu"><i class="fa-solid fa-bars" aria-hidden="true"></i></button>
</nav>
<div id="cm-menu-content">
<div id="cm-menu-items-wrapper">
<div id="cm-menu-scroller">
<ul class="cm-menu-items">
<li class="active"><a href="#" class="sf-house">This page is active</a></li>
</ul>
</div>
</div>
</div>
</div>
<header id="cm-header">
<nav class="cm-navbar cm-navbar-primary">
<button type="button" class="btn btn-primary d-lg-none" data-toggle="cm-menu" aria-label="Toggle menu"><i class="fa-solid fa-bars" aria-hidden="true"></i></button>
<div class="cm-flex"><h1>Put your title here</h1></div>
</nav>
</header>
<div id="global">
<div class="container-fluid">
<div class="card">
<div class="card-body">
<h2 class="m-0">Hello World !</h2>
</div>
</div>
</div>
<footer class="cm-footer"><span class="float-end">© ACME Inc.</span></footer>
</div>
<script src="dist/js/popper.min.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
<script src="dist/js/clearmin.min.js"></script>
</body>
</html>
cm- prefixed.
src/scss/: Sass sources (clearmin.scss is the entry point, _variables.scss holds every setting)src/js/clearmin.js: JavaScript sourcedist/: ready to use files (compiled css/js, Bootstrap, Popper & Font Awesome bundles, fonts, images)demo/ and docs/: demo pages and this documentationCSS files (<head>):
JavaScript files (just before </body>):
cm-no-transition: must be present to prevent browsers from starting transitions on page loadcm-1-navbar: when one navbar is present on your pagecm-2-navbar: when two navbars are present on your pagecm-3-navbar: when three navbars are present on your pagecm-menu-toggled: if you want the menu to be toggled on page load (see next section)When the user chooses the condensed version of the side menu, we want it to stay in this state on the next page. To achieve this, a cookie is automatically set to reflect the menu state.
There are two different ways to restore this state:
.cm-menu-toggled class to the body tag..cm-menu-toggled is automatically added to the body when needed, but it can cause a blinking reflow on some browsers.<div id="global"> to contain the page (e.g. minimal template)<div class="container-fluid"> to contain your content.cm-fix-height to a .row to give the same height to all its cardsClearmin ships two icon sets:
<i class="fa-solid fa-gear"></i>. They take the color of the text, so they are white in colored buttons.dist/css/small-n-flat.css (e.g. <a class="sf-house"> in the left menu). To lighten this file, you may delete the classes you don't use.Left menu links accept either a small-n-flat class or a Font Awesome icon as first child: <a href="#"><i class="fa-solid fa-house"></i>Home</a>.
Clearmin is compiled from the Bootstrap 5.3 Sass sources. Install the dependencies once, then build:
npm install
npm run build # dist/css/clearmin(.min).css, dist/js/clearmin(.min).js + Bootstrap & Popper bundles
npm run watch # recompile dist/css/clearmin.css on change
Every variable of src/scss/_variables.scss is !default: Clearmin specific ones, and the Bootstrap ones it overrides (colors, fonts, spacing...). Here are the Clearmin ones:
$cm-translen-global: 150ms; // Transition duration for layout based animations
$cm-translen-widget: 150ms; // Transition duration for modals, popovers, dropdowns...
$cm-translen-button: 75ms; // Transition duration for .btn items
$cm-menu-width: 262px; // Left menu width
$cm-navbar-height: 50px; // Navbars height (and condensed menu width)
$cm-border-global: #ccc; // Default border color for several items
$cm-underliner-height: 3px; // Height of underline in left menu and nav tabs
$cm-body-bg: #eee; // Page background
$cm-logo: url("../img/logo.svg");
$cm-desktop-breakpoint: lg; // Breakpoint from which the menu is docked
$cm-title-font-size: $font-size-base; // Navbar titles, breadcrumbs, search
$cm-caps-font-size: $font-size-base * .9286; // Uppercase card headers & navbar tabs
$cm-icon-font-size: $font-size-base * 1.2857; // Icons in navbar buttons and menu
$cm-theme-colors: ("gray": ..., "yellow": ..., "purple": ..., "turquoise": ..., "midnight": ...);
The base font size is 16px ($font-size-base: 1rem). Every text related size (headings, buttons, inputs, tables, dropdowns, the variables above...) is a ratio of it, so changing $font-size-base rescales the whole typography proportionally while the layout (navbar height, menu width, gutters) stays the same.
To customize Clearmin without touching its sources, create your own entry file and compile it with node_modules in the Sass load path (sass --load-path=node_modules my-theme.scss):
// my-theme.scss
$primary: #8e44ad;
$cm-menu-width: 240px;
@import "clearmin/src/scss/clearmin";
$primary to reflect the dominant color in a harmonious way.
clearmin.js initializes itself when the DOM is ready. To change the defaults, define window.CMConfig before loading it:
<script>
window.CMConfig = {
navbarHeight: 50, // should reflect the $cm-navbar-height Sass variable
menuSwiper: true, // enable swipe gesture (toggle menu) on touch devices
menuSwiperIOS: true, // enable swipe gesture on iOS Safari
restoreMenuState: true // client-side menu state restoration
}
</script>
<script src="dist/js/clearmin.min.js"></script>
Clearmin also initializes every Bootstrap tooltip ([data-bs-toggle="tooltip"]) and popover ([data-bs-toggle="popover"]) of the page. The instance is available as window.CM (e.g. CM.menu.toggle()).
Clearmin supports Bootstrap 5.3 color modes. Add a toggle button anywhere (its <i> icon switches between moon and sun):
<button type="button" class="btn btn-primary" data-toggle="cm-theme" aria-label="Toggle dark mode"><i class="fa-solid fa-moon"></i></button>
The choice is stored in localStorage (cm-theme); without a choice, the OS preference is followed. To avoid a flash of the wrong mode on page load, add this line in <head>:
<script>try{document.documentElement.dataset.bsTheme=localStorage.getItem('cm-theme')||(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light')}catch(e){}</script>
From JavaScript: CM.theme.set('dark'), CM.theme.get(), and listen to the cm:themechange event on document to update charts & co. Clearmin surfaces are CSS variables (--cm-surface, --cm-body-bg, --cm-border, --cm-muted...) whose dark values are set with the $cm-*-dark Sass variables.
The dark mode has its own "midnight jewel" palette: ink blue surfaces, and deeper jewel tones replacing the flat colors ($cm-theme-colors-dark: sapphire primary, emerald success, copper warning, garnet danger, jade turquoise, amethyst purple...). Each tone has a luminous companion for text on dark surfaces ($cm-theme-colors-dark-emphasis: mint, aqua, apricot, coral...), used by alerts, .text-* / .link-* utilities and form validation; contextual table rows get jewel tinted dark backgrounds. Buttons, navbars, badges, alerts and the --bs-* color variables all switch to it, so charts can read them too (see how the Chart.js charts of the demo dashboards follow the color mode). Set $cm-glow-dark: false to disable the aurora background and glowing accents. In dark mode, the default .cm-navbar-primary header and menu navbars become midnight ($cm-navbar-dark-color, null to keep primary); navbars using another color keep it.
KPI tiles for the top of dashboards (see the sales dashboard):
<div class="card cm-stat">
<div class="card-body">
<div class="cm-stat-icon bg-primary-subtle text-primary-emphasis"><i class="fa-solid fa-cart-shopping"></i></div>
<div class="cm-stat-label">Orders</div>
<div class="cm-stat-value">1,284</div>
<div class="cm-stat-trend text-success"><i class="fa-solid fa-arrow-trend-up"></i> 8.1% <span>vs last month</span></div>
<div class="cm-stat-sparkline"><canvas></canvas></div> <!-- optional -->
</div>
</div>
The optional .cm-stat-sparkline is an edge to edge area at the bottom of the card for a small chart. Charts need a sized, positioned container: .cm-chart (e.g. <div class="cm-chart" style="height:320px"><canvas></canvas></div>). The demo dashboards (sales, website visitors, server stats) use Chart.js (MIT): demo/assets/js/charts.js holds reusable helpers (theme colors, gauges, sparklines, doughnuts, redraw on cm:themechange) and demo/assets/js/dashboard-*.js the charts of each page, including live updating ones. A <span class="badge text-bg-danger cm-live">Live</span> badge shows a pulsing dot.
Sortable, filterable and paginated tables without any plugin (see the data tables demo):
<input type="search" class="form-control" data-cm-table-filter="#customers">
<table id="customers" class="table" data-cm-table data-cm-page-size="10">
<thead>
<tr>
<th data-sort>Name</th>
<th data-sort="number">MRR</th>
<th data-sort="date">Customer since</th>
</tr>
</thead>
<tbody>
<tr><td>Emma Martin</td><td data-value="490">$490</td><td data-value="2024-03-12">Mar 12, 2024</td></tr>
</tbody>
</table>
data-sort makes a column sortable (text by default, number or date); a cell can give its sort value in data-valuedata-cm-page-size enables pagination; an info line and the pagination are added after the tabledata-cm-table-filter="#table-id" filters the rowsShow a notification in the bottom right corner, declaratively or from JavaScript:
<button class="btn btn-primary" data-cm-toast="Your changes have been saved." data-cm-toast-title="Saved" data-cm-toast-color="success">Save</button>
CM.toast('Your changes have been saved.', { title: 'Saved', color: 'success', delay: 4000 })
Follow the official Bootstrap migration guide for the Bootstrap components, then for Clearmin itself:
popper.min.js before bootstrap.min.jsbootstrap-clearmin.min.css is now clearmin.min.css.panel becomes .card (.card-header, .card-body).pull-right is no longer needed; dropdowns use data-bs-toggle="dropdown".popover.cm-popover.bottom + .arrow become .dropdown-menu.cm-popover + .cm-popover-arrow.nav-item / .nav-link, .breadcrumb-item).btn-light (faded button) is renamed .btn-faded, .btn-light being a Bootstrap 5 color.text-overflow is replaced by Bootstrap's .text-truncate.hidden-md.hidden-lg on the header menu button becomes .d-lg-none.md-*) are removed: use Font Awesome 7 icons inside buttons (<i class="fa-solid fa-bars"></i>); Font Awesome 4 class names must be updated (fa fa-cog → fa-solid fa-gear...)