Introduction
MDB package went thought serious refactor and unification process. From file method and event names to compiled file names. We've changed a lot of things to make MDB more consistent and easier to use. Below you can find a list of the most important changes.
Note: The following list is not complete. Only the most key changes are listed, but you should bear in mind that no component has remained unchanged.
Migrating from v6.x.x to v7
After updating the MDB Standard from version 6 to 7, there is a lot of breaking changes that must be introduced in
existing projects to keep them stable. These changes relate in particular to data attributes,
events and method names, compiled file names.
We also made some changes that are not visible to users but affect final product. We've changed bundler that compile files to Vite which allows smaller weight of the package after compilation.
We move from preparing files with compiled modules for every component to using ES modules. Our package will no longer include premade JavaScript modules. That change does not apply to plugins.
In the same fashion we won't include CSS modules anymore. To reduce bundle size of CSS in your project we recommend the use of PurgeCSS. Our tutorial for including PurgeCSS in yur project is available here.
Charts became separate file now which makes no difference when migrating to UMD format, but if user is going to
use ES imports then charts needs to be imported from chart.es.min.js file as separate module.
JavaScript
There was a lot of changes to our source and compiled JavaScript files. We are going to no longer include in the package files with compiled modules for every component.
In the new version we are introducing new, modular approach. Now user will be able to use ES or
UMD formats for all components. These formats will differ in the way components are initialized and will be used in different cases.
Which format should you choose?
If your application:
- is based on
modules - uses
bundlerfunctionality - needs
treeshaking
the ES format will be most suitable for you, otherwise
UMD is the way to go.
What is the difference between MDB ES and UMD formats in MDB?
In short, the way to initialize components. In order to allow bundlers to
perform proper treeshaking, we have moved component initialization to the
initMDB method. MDB in UMD format
will work without adding more elements, but will lack treeshaking. MDB in ES format, on the other
hand, allows components to be used as separate modules, resulting in the much smaller build size.
If you are not using bundlers, you should use the UMD format.
Using charts with ES import
The mdb.es.min.js does not include charts component. If you plan to use charts within your project, when using
ES import, charts needs to be imported from chart.es.min.js file as separate module.
About the initMDB method
To use the initMDB method, you need to import it from the
mdb-ui-kit, same as for components. You can provide a second
argument that will be an object with options that you want to pass to the
init method.
How to use the initMDB method?
Import the method from the mdb-ui-kit package inside your
project js file and call it with the components you want to
initialize.
import { Datepicker, Input, initMDB } from "mdb-ui-kit";
initMDB({ Datepicker, Input });
Initialization
To initialize component we are now using data attributes unified through all components and plugins. Attribute is
created using pattern data-mdb-{component-name}-init e.g. data-mdb-input-init. With UMD
import that is all what is needed to run component. With ES import there is a need to allow auto init
with initMDB method for component used on the page. More about that in this section.
Free components
Here is a list of modifications required in free components to maintain their current functionality if they were automatically initialized upon page load.
- Accordion - add
data-mdb-collapse-initattribute to.accordion-button. - Alert - add
data-mdb-alert-initattribute to.alert. - Button - add
data-mdb-button-initto.btnif your using fixed buttons or toggle buttons, also adddata-mdb-ripple-initattribute if you want to have ripple effect on button click. - Carousel - add
data-mdb-carousel-initattribute to.carousel. - Collapse - add
data-mdb-collapse-initattribute to collapse toggler, previously used attributedata-mdb-toggle="collapse"can be safely removed. - Dropdown - add
data-mdb-dropdown-initattribute to.dropdown-toggleand adddata-mdb-ripple-initattribute to button if you want to keep ripple effect on button click, previously used attributedata-mdb-toggle="dropdown"can be safely removed. - Input - add
data-mdb-input-initto.form-outline. - Modal - add
data-mdb-modal-initattribute to toggle button, previously used attributedata-mdb-toggle="modal"can be safely removed. - Popovers - add
data-mdb-popover-initattribute, previously used attributedata-mdb-toggle="popover"can be safely removed, adddata-mdb-ripple-initattribute to button if you want to keep ripple effect on button click. - Range - add
data-mdb-range-initto.range. - Ripple - add
data-mdb-ripple-initto element you want to use ripple effect on, previously used class.ripplecan be safely removed. - Scrollspy - add
data-mdb-scrollspy-initattribute on the element you’re spying on, previously used attributedata-mdb-spy="scroll"can be safely removed. - Tabs - add
data-mdb-tab-initto every.nav-link, previously used attributedata-mdb-toggle="tab"can be safely removed. - Pills - add
data-mdb-pill-initto every.nav-link, previously used attributedata-mdb-toggle="pill"can be safely removed. - Toast - add
data-mdb-toast-initto.toast. - Tooltip - add
data-mdb-tooltip-initattribute, previously used attributedata-mdb-toggle="tooltip"can be safely removed, adddata-mdb-ripple-initattribute to button if you want to keep ripple effect on button click.
Pro components
Here is a list of modifications required in pro components to maintain their current functionality if they were automatically initialized upon page load.
- Charts - add
data-mdb-chart-initattribute tocanvastag. - Chips - add
data-mdb-chips-input-initattribute to Chips Input. - Chip - add
data-mdb-chip-initattribute to.chip. - Datatable - add
data-mdb-datatable-initattribute to.datatable. - Datetimepicker - add
data-mdb-datetimepicker-initto.form-outline, previously used class.datetimepickercan be safely removed. - Datepicker - add
data-mdb-datepicker-initanddata-mdb-input-initto.form-outline, previously used class.datepickercan be safely removed. - Loading management - add
data-mdb-loading-initattribute to.loading-iconparent element, previously used class.loadingcan be safely removed. - Multi Range - add
data-mdb-multi-range-slider-initattribute to.multi-range-slider. - Select - add
data-mdb-select-inittoselecttag, previously used class.selectcan be safely removed. - Timepicker - add
data-mdb-timepicker-initanddata-mdb-input-initto.form-outline. - Alert - add
data-mdb-alert-initattribute to.alert. - Animate - add
data-mdb-animation-initto element you want to use animation on previously used attributedata-mdb-toggle="animation"can be safely removed. - Clipboard - add
data-mdb-clipboard-initto element you want to copy, previously used class.clipboardcan be safely removed. - Infinite Scroll - add
data-mdb-infinite-scroll-initto container element, previously used class.infinite-scrollcan be safely removed. - Lazy Load - add
data-mdb-lazy-load-initto container element, previously used class.lazycan be safely removed. - Lightbox - add
data-mdb-lightbox-initto.lightbox. - Modal - add
data-mdb-modal-initattribute to toggle button, previously used attributedata-mdb-toggle="modal"can be safely removed. - Navbar - add
data-mdb-navbar-initto.navbar, it is needed only if you are using animated navbar. - Perfect Scrollbar - add
data-mdb-perfect-scrollbar-initto element that need scroll, previously used attributedata-mdb-perfect-scrollbar='true'can be safely removed. - Popconfirm - add
data-mdb-popconfirm-initto.btnand adddata-mdb-ripple-initattribute to button if you want to keep ripple effect on button click. - Rating - add
data-mdb-rating-initto.rating, previously used attributedata-mdb-toggle='rating'can be safely removed. - Sidenav - add
data-mdb-sidenav-initto.sidenav. - Smooth Scroll - add
data-mdb-smooth-scroll-inittoatag, previously used attributedata-mdb-smooth-scroll="smooth-scroll"can be safely removed. - Stepper - add
data-mdb-stepper-initto.stepper, previously used attributedata-mdb-stepper="stepper"can be safely removed. - Sticky - add
data-mdb-sticky-initto.sticky. - Toast - add
data-mdb-toast-initto.toast.
We've introduced the capability to initialize the Touch component using data-mdb-touch-init data attribute.
Plugins
Here is a list of plugins that require modifications to maintain their current functionality if they were automatically initialized upon page load.
- Calendar - add
data-mdb-calendar-initattribute to.calendar. - Captcha - add
data-mdb-captcha-initattribute to.captcha. - Color Picker - add
data-mdb-color-picker-initattribute to.color-picker, previously used attributedata-mdb-picker="color-picker"should be removed. - Countdown - add
data-mdb-countdown-initattribute. - Drag And Drop - add
data-mdb-draggable-initattribute todraggable-elementanddata-mdb-sortable-initattribute tosortable-list, previously used attributedata-mdb-sortable="sortable"should be removed. - Dummy - add
data-mdb-dummy-initattribute, previously used classdummycan be safely removed. - Ecommerce Gallery - add
data-mdb-ecommerce-gallery-initattribute to.ecommerce-gallery. - File Upload - add
data-mdb-file-upload-initattribute toinputtag, previously used attributedata-mdb-file-upload="file-upload"should be removed. - Input Mask - add
data-mdb-input-mask-initattribute toinputtag anddata-mdb-input-initto.form-outline. - Mention - add
data-mdb-mention-initattribute toinputtag anddata-mdb-input-initto.form-outline, previously used class.mentioncan be safely removed. - Multi Item Carousel - add
data-mdb-multi-carousel-initattribute to.multi-carousel. - Onboarding - add
data-mdb-onboarding-initattribute, previously used class.onboardingcan be safely removed. - Parallax - add
data-mdb-parallax-initattribute, previously used class.parallaxcan be safely removed. - Scroll Status - add
data-mdb-scroll-status-initattribute to.scroll-status. - Table Editor - add
data-mdb-table-editor-initattribute to.table-editor. - TreeTable - add
data-mdb-treetable-initattribute to.treeview. - Treeview - add
data-mdb-treeview-initattribute to.treetable. - Vector Maps - add
data-mdb-vector-map-initattribute to.vector-map. - WYSIWYG Editor - add
data-mdb-wysiwyg-initattribute to.wysiwyg, previously used attributedata-mdb-wysiwyg="wysiwyg"should be removed.
We've introduced the capability to initialize the Filters plugin using the data attribute data-mdb-filters-init.
Additionally, if you were using JavaScript to initialize the Input mask, please note that the
class name has been changed from
Inputmask to InputMask.
Events
We've decided to change names of events to more meaningful and uniform throughout components and plugins. We also introduced few new events to expand possible interactions with components.
Components
Chips:- Renamed
add.mdb.chipsevent toadded.mdb.chips. - Added
add.mdb.chipsevent.
- Renamed
Datatable:- Renamed
selectRows.mdb.datatableevent torowSelected.mdb.datatable. - Renamed
rowClick.mdb.datatableevent torowClicked.mdb.datatable.
- Renamed
-
Datetimepicker- RenameddatetimeChange.mdb.datetimepickerevent tovalueChanged.mdb.datetimepicker. -
Datepicker- RenameddateChange.mdb.datepickerevent tovalueChanged.mdb.datepicker. Multi Range:- Removed
showPercent.mdb.multiRangeSliderevent. - Renamed
value.mdb.multiRangeSliderevent tovalueChanged.mdb.multiRangeSlider.
- Removed
Select:- Renamed
valueChange.mdb.selectevent tovalueChanged.mdb.select. - Renamed
optionSelect.mdb.selectevent tooptionSelected.mdb.select. - Renamed
optionDeselect.mdb.selectevent tooptionDeselected.mdb.select. - Renamed
shown.mdb.selectevent toopened.mdb.select. - Renamed
value.mdb.hiddenevent toclosed.mdb.select.
- Renamed
-
Timepicker- Renamedinput.mdb.timepickerevent tovalueChanged.mdb.timepicker. -
Clipboard- Renamedcopy.mdb.clipboardevent tocopied.mdb.clipboard. -
Infinite scroll- Renamedcomplete.mdb.Infinite scrollevent tocompleted.mdb.Infinite scroll. Lazy loading:- Renamed
onLoad.mdb.lazyevent tocontentLoaded.mdb.lazyLoad. - Renamed
onError.mdb.lazyevent toloadingError.mdb.lazyLoad.
- Renamed
-
Lightbox- Renamedslided.mdb.lightboxevent toslid.mdb.lightbox. Rating:- Renamed
onSelect.mdb.ratingevent toscoreSelect.mdb.rating. - Renamed
onHover.mdb.ratingevent toscoreHover.mdb.rating.
- Renamed
Stepper:- Renamed
onChangeStep.mdb.stepperevent tostepChange.mdb.stepper. - Renamed
onValid.mdb.stepperevent tostepValid.mdb.stepper. - Renamed
onInvalid.mdb.stepperevent tostepInvalid.mdb.stepper. - Added
stepChanged.mdb.stepperevent.
- Renamed
Sticky:- Renamed
active.mdb.stickyevent toactivated.mdb.sticky. - Renamed
inactive.mdb.stickyevent todeactivated.mdb.sticky.
- Renamed
Plugins
Captcha:- Renamed
onExpire.mdb.captchaevent tocaptchaExpire.mdb.captcha. - Renamed
onError.mdb.captchaevent tocaptchaError.mdb.captcha. - Renamed
onSuccess.mdb.captchaevent tocaptchaSuccess.mdb.captcha.
- Renamed
Color Picker:- Renamed
onOpen.mdb.colorPickerevent toopen.mdb.colorPicker. - Renamed
onClose.mdb.colorPickerevent toclose.mdb.colorPicker. - Renamed
onChange.mdb.colorPickerevent tocolorChanged.mdb.colorPicker.
- Renamed
Drag and drop:- Renamed
move.mdb.draggableevent toitemMove.mdb.draggable. - Renamed
move.mdb.sortableevent toitemMove.mdb.sortable. - Renamed
exit.mdb.sortableevent tolistChange.mdb.sortable.
- Renamed
File Upload- Renamederror.mdb.fileUploadevent toerror.mdb.fileError.Input Mask:- Renamed
input.mdb.input-maskevent tovalueChanged.mdb.inputMask. - Renamed
complete.mdb.input-maskevent tocompleted.mdb.inputMask.
- Renamed
Mention:- Renamed
select.mdb.mentionevent toitemSelected.mdb.mention. - Renamed
change.mdb.mentionevent tovalueChange.mdb.mention. - Renamed
fetch-error.mdb.mentionevent tofetchError.mdb.mention.
- Renamed
Multi item carousel- Renamedslided.mdb.multiCarouselevent toslid.mdb.multiCarousel.Onboarding- Renamedprevious.mdb.onboardingevent toprev.mdb.onboarding.Table editor:- Renamed
exit.mdb.tableEditorevent toeditorExit.mdb.tableEditor. - Added
editorOpen.mdb.tableEditorevent.
- Renamed
Transfer:- Renamed
onChange.mdb.transferevent tolistChange.mdb.transfer. - Renamed
onSearch.mdb.transferevent tosearch.mdb.transfer. - Renamed
onSelect.mdb.transferevent toitemSelected.mdb.transfer.
- Renamed
Treeview:- Renamed
select.mdb.treeviewevent toitemSelected.mdb.treeview. - Renamed
activeItem.mdb.treeviewevent toitemActive.mdb.treeview.
- Renamed
Vector maps- Renamedselectevent toareaSelect.mdb.vectorMaps.
Methods
Same as events some method names were changed for the sake of unification or to accommodate new functionality.
Touch- Removedinitmethod. It was moved to constructor and it runs automatically now.Loading Management- Removedtogglemethod.Autocomplete- RenamedinitSearchmethod tosearch.Stepper- RenamedpreviousStepmethod toprevStep.Sticky:- Renamed
activemethod toactivate. -
Renamed
inactivemethod todeactivate.
- Renamed
Other changes
There were other changes made to the package.
Dummy:- Option
dummyTextLengthwas removed. To replace it usedummyTextoption, keeping previous value.
- Option
Scroll status:- Renamed
.scrollStatusclass to.scroll-status. - Renamed
.scrollStatus-progressclass to.scroll-status-progress.
- Renamed
Input mask:- Changed plugin
NAMEfrominput-masktoinputMask.
- Changed plugin