CDN Quickstart
The official guide for how to include Modus Bootstrap’s CSS and Bootstrap’s JavaScript in your project using a CDN.
Get started using Modus Bootstrap in seconds by including our production-ready CSS and JavaScript by using a CDN without the need for any build steps. CDNs provide copies of Modus Bootstrap’s codebase that’s ready to be used in any environment with minimal code changes required on your part.
Live demo
Already familiar with setting up HTML pages? See the end result in this Bootstrap CodePen demo.
Steps
-
Create a new
index.htmlfile in your project root. Include the<meta name="viewport">tag as well for proper responsive behavior in mobile devices.<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Modus Bootstrap demo</title> </head> <body> <h1>Hello, world!</h1> </body> </html> -
Include Modus Bootstrap’s CSS and Bootstrap’s JS. Place the
<link>tag in the<head>for our CSS, and the<script>tag for our JavaScript bundle (including Floating UI for positioning menus, popovers, and tooltips, and Vanilla Calendar Pro for the datepicker) before the closing</body>. Learn more about our CDN links.<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Modus Bootstrap demo</title> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/modus-bootstrap.min.css" rel="stylesheet"> </head> <body> <h1>Hello, world!</h1> <script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-+PW0IDVGGwmpaBQvcXY+W0BcpHpITFB3dSfSoGvDdHtLbrLpSbpGcvtQRM/BJpz+" crossorigin="anonymous"></script> </body> </html>Choose the JavaScript file that fits your setup:
bootstrap.bundle.jsincludes Floating UI and Vanilla Calendar Pro. You can load it directly with<script type="module">.bootstrap.jsreferences both dependencies. When you load it directly in a browser, you must provide both dependencies through an import map.
Use this import map with the non-bundle file:
<script type="importmap"> { "imports": { "@floating-ui/dom": "https://cdn.jsdelivr.net/npm/@floating-ui/[email protected]/dist/floating-ui.dom.esm.min.js", "vanilla-calendar-pro": "https://cdn.jsdelivr.net/npm/[email protected]/index.mjs" } } </script> <script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-3Yo3YCoxUQZoPH8he5dQIEAZ/k/vBTLYf1CFU5hE7GYPzQZu3dYpWvBwWKxN+HJZ" crossorigin="anonymous"></script>To omit either dependency, import only the Modus Bootstrap components you use or use a bundler with tree shaking.
-
Hello, world! Open the page in your browser of choice to see your Bootstrapped page. Now you can start building with Modus Bootstrap by creating your own layout, adding dozens of components, and utilizing our official examples.
Optional font
Modus Bootstrap's source code defaults to a native font stack, but we use a custom font for our hosted documentation to for more consistent styling across platforms. We use Open Sans, and recommend using the same or similar in your project.
-
Add the Open Sans web font from Google Fonts. Add the following to your
<head>, before Modus Bootstrap’s CSS:<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Modus Bootstrap demo</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/modus-bootstrap.min.css" rel="stylesheet"> </head> <body> <h1>Hello, world!</h1> <script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> </body> </html> -
Apply the font by overriding Modus Bootstrap’s CSS variable. You can do this in a
<style>tag in your<head>or in a custom CSS file.<style> :root { --bs-body-font-family: "Open Sans", system-ui, sans-serif; } </style>You can also do the same in your custom Sass file should you graduate from a CDN setup to one that includes Modus Bootstrap via a package manager.
Learn more about Modus Bootstrap’s typography defaults in Typography and Reboot.