Daemonite Material v4.6
website·Indexed 31 days ago
https://djibe.github.io/material/A Material Design implementation for Bootstrap 4.6. This documentation covers Material components such as data tables, tooltips, steppers, expansion panels, navigation drawers, and text fields, alongside Bootstrap layout grids, utilities, and migration guides.
What's inside Daemonite Material
- Material Design for Bootstrap is a front-end framework that combines the HTML markup and technology of Bootstrap with the visual language of Google Material Design. It allows developers to use standard Bootstrap markup while achieving a Material Design aesthetic. The project provides styling for existing Bootstrap components and introduces unique Material Design components (like floating buttons, pickers, and steppers) that require specific additional markup.
Overview of Top App Bars in Material Design
The top app bar is a UI component used to provide branding, screen titles, navigation, and actions related to the current screen. It is designed to be flexible and can transform into a contextual action bar depending on the application state.Implement a Circular Progress indicator
Circular progress indicators are used to inform users about the status of ongoing processes. They are constructed using a nested group of HTML elements. To change the color of the spinner, add a color modifier class to the root.progress-circularelement. Supported modifiers include brand colors (-primary,-secondary) and helper colors (-danger,-info,-success,-warning).<!-- Default Circular Progress --> <div class="progress-circular"> <div class="progress-circular-wrapper"> <div class="progress-circular-inner"> <div class="progress-circular-left"> <div class="progress-circular-spinner"></div> </div> <div class="progress-circular-gap"></div> <div class="progress-circular-right"> <div class="progress-circular-spinner"></div> </div> </div> </div> </div>
<!-- Primary Colored Circular Progress --> <div class="progress-circular progress-circular-primary"> <div class="progress-circular-wrapper"> <div class="progress-circular-inner"> <div class="progress-circular-left"> <div class="progress-circular-spinner"></div> </div> <div class="progress-circular-gap"></div> <div class="progress-circular-right"> <div class="progress-circular-spinner"></div> </div> </div> </div> </div>
Understand the Bootstrap source code directory structure
The full Bootstrap source code download contains both precompiled assets and the original source files. Thedist/directory contains the precompiled CSS and JS. Thescss/andjs/directories contain the source Sass and JavaScript. Thesite/docs/directory contains the documentation source and usage examples.bootstrap/ ├── dist/ # Precompiled CSS and JS ├── site/ # Documentation and examples ├── js/ # Source JavaScript └── scss/ # Source SassListen to Bootstrap carousel events
Bootstrap's carousel component triggers events on the carousel element (
<div class="carousel">). These events provide metadata about the transition, including thedirection("left" or "right"), therelatedTarget(the DOM element sliding into place), thefromindex, and thetoindex.Available events:
slide.bs.carousel: Fires immediately when the slide method is invoked.slid.bs.carousel: Fires after the carousel has completed its slide transition.
$('#myCarousel').on('slide.bs.carousel', function () { // do something... })Ensure accessibility compliance with Material UI
Material UI components are designed to be compatible with WCAG 2.1 (A/AA/AAA) and Section 508 standards. However, overall accessibility depends on the developer's implementation of markup, additional styling, and scripting. Interactive components (modals, dropdowns, tooltips) use WAI-ARIA roles and attributes to support touch, mouse, keyboard, and screen reader users. Because components are generic, developers may need to add specific ARIA roles or JavaScript behavior to accurately convey a component's precise functionality.Tab component events lifecycle
When a new tab is activated, the following events fire in sequence:
hide.bs.tab: Fires on the current active tab.show.bs.tab: Fires on the tab about to be shown.hidden.bs.tab: Fires on the previous active tab.shown.bs.tab: Fires on the newly active tab after the transition completes.
Note: If no tab was previously active,
hide.bs.tabandhidden.bs.tabwill not fire.Understand the Bootstrap 4 Reboot CSS approach
Reboot is a CSS reset that builds upon Normalize. It provides opinionated baseline styles using only element selectors, ensuring that additional styling is handled via classes. Key design principles include:
- Using
reminstead ofemfor scalable component spacing. - Avoiding
margin-topto prevent margin collapse and simplify the mental model. - Using
remfor block element margins to facilitate scaling across device sizes. - Minimizing font-related property declarations, preferring
inheritwhere possible.
- Using
Create a basic Card container
A card is a flexible content container built with flexbox. By default, cards have no fixed width and will fill the full width of their parent element. They also have no default margin, so spacing utilities should be used as needed.<div class="card" style="width: 18rem;"> <img loading="lazy" class="card-img-top" src=".../100px180/" alt="Image cap"> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>Implement a basic pagination component
Create a pagination component using a wrapping<nav>element for accessibility, containing a<ul>with the.paginationclass. Each page link should be wrapped in an<li>with the.page-itemclass and use an<a>tag with the.page-linkclass. It is recommended to provide a descriptivearia-labelon the<nav>element to identify the purpose of the navigation (e.g.,aria-label="Search results pages").<nav aria-label="Page navigation example"> <ul class="pagination"> <li class="page-item"><a class="page-link" href="#">Previous</a></li> <li class="page-item"><a class="page-link" href="#">1</a></li> <li class="page-item"><a class="page-link" href="#">2</a></li> <li class="page-item"><a class="page-link" href="#">3</a></li> <li class="page-item"><a class="page-link" href="#">Next</a></li> </ul> </nav>Vertically align flex items in a column
To move a specific flex item to the top or bottom of a container, combineflex-direction: columnwithalign-itemsand auto margins (mt-autoormb-auto).<!-- Push item to the bottom of a 200px column --> <div class="d-flex align-items-end flex-column" style="height: 200px;"> <div>Item 1</div> <div>Item 2</div> <div class="mt-auto">Item 3 (at bottom)</div> </div>Implement a basic Snackbar using Bootstrap toast markup
Snackbars are temporary notifications that appear at the bottom of the screen. They are implemented using default Bootstrap toast HTML markup. To ensure the default centered bottom alignment, wrap the toast in a.toast-container. Use thedata-delayattribute (in milliseconds) to control how long the snackbar remains visible; recommended durations are between 4000ms and 10000ms.<div class="toast-container"> <div class="toast" id="toast-example1" role="alert" aria-live="assertive" aria-atomic="true" data-delay="4000"> <div class="toast-header"> Saved in "Wedding" album </div> </div> </div>