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
bundler
functionality - 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-init
attribute to.accordion-button
. - Alert - add
data-mdb-alert-init
attribute to.alert
. - Button - add
data-mdb-button-init
to.btn
if your using fixed buttons or toggle buttons, also adddata-mdb-ripple-init
attribute if you want to have ripple effect on button click. - Carousel - add
data-mdb-carousel-init
attribute to.carousel
. - Collapse - add
data-mdb-collapse-init
attribute to collapse toggler, previously used attributedata-mdb-toggle="collapse"
can be safely removed. - Dropdown - add
data-mdb-dropdown-init
attribute to.dropdown-toggle
and adddata-mdb-ripple-init
attribute 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-init
to.form-outline
. - Modal - add
data-mdb-modal-init
attribute to toggle button, previously used attributedata-mdb-toggle="modal"
can be safely removed. - Popovers - add
data-mdb-popover-init
attribute, previously used attributedata-mdb-toggle="popover"
can be safely removed, adddata-mdb-ripple-init
attribute to button if you want to keep ripple effect on button click. - Range - add
data-mdb-range-init
to.range
. - Ripple - add
data-mdb-ripple-init
to element you want to use ripple effect on, previously used class.ripple
can be safely removed. - Scrollspy - add
data-mdb-scrollspy-init
attribute on the element you’re spying on, previously used attributedata-mdb-spy="scroll"
can be safely removed. - Tabs - add
data-mdb-tab-init
to every.nav-link
, previously used attributedata-mdb-toggle="tab"
can be safely removed. - Pills - add
data-mdb-pill-init
to every.nav-link
, previously used attributedata-mdb-toggle="pill"
can be safely removed. - Toast - add
data-mdb-toast-init
to.toast
. - Tooltip - add
data-mdb-tooltip-init
attribute, previously used attributedata-mdb-toggle="tooltip"
can be safely removed, adddata-mdb-ripple-init
attribute 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-init
attribute tocanvas
tag. - Chips - add
data-mdb-chips-input-init
attribute to Chips Input. - Chip - add
data-mdb-chip-init
attribute to.chip
. - Datatable - add
data-mdb-datatable-init
attribute to.datatable
. - Datetimepicker - add
data-mdb-datetimepicker-init
to.form-outline
, previously used class.datetimepicker
can be safely removed. - Datepicker - add
data-mdb-datepicker-init
anddata-mdb-input-init
to.form-outline
, previously used class.datepicker
can be safely removed. - Loading management - add
data-mdb-loading-init
attribute to.loading-icon
parent element, previously used class.loading
can be safely removed. - Multi Range - add
data-mdb-multi-range-slider-init
attribute to.multi-range-slider
. - Select - add
data-mdb-select-init
toselect
tag, previously used class.select
can be safely removed. - Timepicker - add
data-mdb-timepicker-init
anddata-mdb-input-init
to.form-outline
. - Alert - add
data-mdb-alert-init
attribute to.alert
. - Animate - add
data-mdb-animation-init
to element you want to use animation on previously used attributedata-mdb-toggle="animation"
can be safely removed. - Clipboard - add
data-mdb-clipboard-init
to element you want to copy, previously used class.clipboard
can be safely removed. - Infinite Scroll - add
data-mdb-infinite-scroll-init
to container element, previously used class.infinite-scroll
can be safely removed. - Lazy Load - add
data-mdb-lazy-load-init
to container element, previously used class.lazy
can be safely removed. - Lightbox - add
data-mdb-lightbox-init
to.lightbox
. - Modal - add
data-mdb-modal-init
attribute to toggle button, previously used attributedata-mdb-toggle="modal"
can be safely removed. - Navbar - add
data-mdb-navbar-init
to.navbar
, it is needed only if you are using animated navbar. - Perfect Scrollbar - add
data-mdb-perfect-scrollbar-init
to element that need scroll, previously used attributedata-mdb-perfect-scrollbar='true'
can be safely removed. - Popconfirm - add
data-mdb-popconfirm-init
to.btn
and adddata-mdb-ripple-init
attribute to button if you want to keep ripple effect on button click. - Rating - add
data-mdb-rating-init
to.rating
, previously used attributedata-mdb-toggle='rating'
can be safely removed. - Sidenav - add
data-mdb-sidenav-init
to.sidenav
. - Smooth Scroll - add
data-mdb-smooth-scroll-init
toa
tag, previously used attributedata-mdb-smooth-scroll="smooth-scroll"
can be safely removed. - Stepper - add
data-mdb-stepper-init
to.stepper
, previously used attributedata-mdb-stepper="stepper"
can be safely removed. - Sticky - add
data-mdb-sticky-init
to.sticky
. - Toast - add
data-mdb-toast-init
to.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-init
attribute to.calendar
. - Captcha - add
data-mdb-captcha-init
attribute to.captcha
. - Color Picker - add
data-mdb-color-picker-init
attribute to.color-picker
, previously used attributedata-mdb-picker="color-picker"
should be removed. - Countdown - add
data-mdb-countdown-init
attribute. - Drag And Drop - add
data-mdb-draggable-init
attribute todraggable-element
anddata-mdb-sortable-init
attribute tosortable-list
, previously used attributedata-mdb-sortable="sortable"
should be removed. - Dummy - add
data-mdb-dummy-init
attribute, previously used classdummy
can be safely removed. - Ecommerce Gallery - add
data-mdb-ecommerce-gallery-init
attribute to.ecommerce-gallery
. - File Upload - add
data-mdb-file-upload-init
attribute toinput
tag, previously used attributedata-mdb-file-upload="file-upload"
should be removed. - Input Mask - add
data-mdb-input-mask-init
attribute toinput
tag anddata-mdb-input-init
to.form-outline
. - Mention - add
data-mdb-mention-init
attribute toinput
tag anddata-mdb-input-init
to.form-outline
, previously used class.mention
can be safely removed. - Multi Item Carousel - add
data-mdb-multi-carousel-init
attribute to.multi-carousel
. - Onboarding - add
data-mdb-onboarding-init
attribute, previously used class.onboarding
can be safely removed. - Parallax - add
data-mdb-parallax-init
attribute, previously used class.parallax
can be safely removed. - Scroll Status - add
data-mdb-scroll-status-init
attribute to.scroll-status
. - Table Editor - add
data-mdb-table-editor-init
attribute to.table-editor
. - TreeTable - add
data-mdb-treetable-init
attribute to.treeview
. - Treeview - add
data-mdb-treeview-init
attribute to.treetable
. - Vector Maps - add
data-mdb-vector-map-init
attribute to.vector-map
. - WYSIWYG Editor - add
data-mdb-wysiwyg-init
attribute 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.chips
event toadded.mdb.chips
. - Added
add.mdb.chips
event.
- Renamed
Datatable
:- Renamed
selectRows.mdb.datatable
event torowSelected.mdb.datatable
. - Renamed
rowClick.mdb.datatable
event torowClicked.mdb.datatable
.
- Renamed
-
Datetimepicker
- RenameddatetimeChange.mdb.datetimepicker
event tovalueChanged.mdb.datetimepicker
. -
Datepicker
- RenameddateChange.mdb.datepicker
event tovalueChanged.mdb.datepicker
. Multi Range
:- Removed
showPercent.mdb.multiRangeSlider
event. - Renamed
value.mdb.multiRangeSlider
event tovalueChanged.mdb.multiRangeSlider
.
- Removed
Select
:- Renamed
valueChange.mdb.select
event tovalueChanged.mdb.select
. - Renamed
optionSelect.mdb.select
event tooptionSelected.mdb.select
. - Renamed
optionDeselect.mdb.select
event tooptionDeselected.mdb.select
. - Renamed
shown.mdb.select
event toopened.mdb.select
. - Renamed
value.mdb.hidden
event toclosed.mdb.select
.
- Renamed
-
Timepicker
- Renamedinput.mdb.timepicker
event tovalueChanged.mdb.timepicker
. -
Clipboard
- Renamedcopy.mdb.clipboard
event tocopied.mdb.clipboard
. -
Infinite scroll
- Renamedcomplete.mdb.Infinite scroll
event tocompleted.mdb.Infinite scroll
. Lazy loading
:- Renamed
onLoad.mdb.lazy
event tocontentLoaded.mdb.lazyLoad
. - Renamed
onError.mdb.lazy
event toloadingError.mdb.lazyLoad
.
- Renamed
-
Lightbox
- Renamedslided.mdb.lightbox
event toslid.mdb.lightbox
. Rating
:- Renamed
onSelect.mdb.rating
event toscoreSelect.mdb.rating
. - Renamed
onHover.mdb.rating
event toscoreHover.mdb.rating
.
- Renamed
Stepper
:- Renamed
onChangeStep.mdb.stepper
event tostepChange.mdb.stepper
. - Renamed
onValid.mdb.stepper
event tostepValid.mdb.stepper
. - Renamed
onInvalid.mdb.stepper
event tostepInvalid.mdb.stepper
. - Added
stepChanged.mdb.stepper
event.
- Renamed
Sticky
:- Renamed
active.mdb.sticky
event toactivated.mdb.sticky
. - Renamed
inactive.mdb.sticky
event todeactivated.mdb.sticky
.
- Renamed
Plugins
Captcha
:- Renamed
onExpire.mdb.captcha
event tocaptchaExpire.mdb.captcha
. - Renamed
onError.mdb.captcha
event tocaptchaError.mdb.captcha
. - Renamed
onSuccess.mdb.captcha
event tocaptchaSuccess.mdb.captcha
.
- Renamed
Color Picker
:- Renamed
onOpen.mdb.colorPicker
event toopen.mdb.colorPicker
. - Renamed
onClose.mdb.colorPicker
event toclose.mdb.colorPicker
. - Renamed
onChange.mdb.colorPicker
event tocolorChanged.mdb.colorPicker
.
- Renamed
Drag and drop
:- Renamed
move.mdb.draggable
event toitemMove.mdb.draggable
. - Renamed
move.mdb.sortable
event toitemMove.mdb.sortable
. - Renamed
exit.mdb.sortable
event tolistChange.mdb.sortable
.
- Renamed
File Upload
- Renamederror.mdb.fileUpload
event toerror.mdb.fileError
.Input Mask
:- Renamed
input.mdb.input-mask
event tovalueChanged.mdb.inputMask
. - Renamed
complete.mdb.input-mask
event tocompleted.mdb.inputMask
.
- Renamed
Mention
:- Renamed
select.mdb.mention
event toitemSelected.mdb.mention
. - Renamed
change.mdb.mention
event tovalueChange.mdb.mention
. - Renamed
fetch-error.mdb.mention
event tofetchError.mdb.mention
.
- Renamed
Multi item carousel
- Renamedslided.mdb.multiCarousel
event toslid.mdb.multiCarousel
.Onboarding
- Renamedprevious.mdb.onboarding
event toprev.mdb.onboarding
.Table editor
:- Renamed
exit.mdb.tableEditor
event toeditorExit.mdb.tableEditor
. - Added
editorOpen.mdb.tableEditor
event.
- Renamed
Transfer
:- Renamed
onChange.mdb.transfer
event tolistChange.mdb.transfer
. - Renamed
onSearch.mdb.transfer
event tosearch.mdb.transfer
. - Renamed
onSelect.mdb.transfer
event toitemSelected.mdb.transfer
.
- Renamed
Treeview
:- Renamed
select.mdb.treeview
event toitemSelected.mdb.treeview
. - Renamed
activeItem.mdb.treeview
event toitemActive.mdb.treeview
.
- Renamed
Vector maps
- Renamedselect
event toareaSelect.mdb.vectorMaps
.
Methods
Same as events some method names were changed for the sake of unification or to accommodate new functionality.
Touch
- Removedinit
method. It was moved to constructor and it runs automatically now.Loading Management
- Removedtoggle
method.Autocomplete
- RenamedinitSearch
method tosearch
.Stepper
- RenamedpreviousStep
method toprevStep
.Sticky
:- Renamed
active
method toactivate
. -
Renamed
inactive
method todeactivate
.
- Renamed
Other changes
There were other changes made to the package.
Dummy
:- Option
dummyTextLength
was removed. To replace it usedummyText
option, keeping previous value.
- Option
Scroll status
:- Renamed
.scrollStatus
class to.scroll-status
. - Renamed
.scrollStatus-progress
class to.scroll-status-progress
.
- Renamed
Input mask
:- Changed plugin
NAME
frominput-mask
toinputMask
.
- Changed plugin