Migrating to Newer SMUI Versions
This doc contains information that will help you migrate your code from an older version of SMUI to a newer one. Things that you will need to change in your existing code will be written here. It would also be helpful to check the MDC changelog if the upstream MDC versions has changed between SMUI versions.
SMUI 5 -> SMUI 6
SMUI 6 migrated to upstream MDC 13.0 from 11.0: https://github.com/material-components/material-components-web/blob/master/CHANGELOG.md#1300-2021-09-24
Breaking Changes
- For
@smui/common,@smui/textfield,@smui/select, and@smui/snackbar, if you ever import something like@smui/snackbar/kitchen/indexor@smui/textfield/helper-text/index, you need to remove the/indexfrom the end of that import. (This does not apply to Sass imports.)- Here’s a regex you can use in VS Code to search for these: @smui/(common|textfield|select|snackbar)/[\w-]+/index
- The ‘/styled’ import endpoints have been removed. You will need to import the ‘/index’ endpoint from Sass yourself if you were using the Advanced Styling Method.
Components
- Switch
- No longer emits “change” event, use “SMUISwitch:change” event instead.
Changes
- MDC events are now dispatched with “SMUI” instead of “MDC” prefix. They are dispatched as both though, so your code shouldn’t break. You should still update your code to use the new “SMUI” prefix anyway.
- There’s no longer any required Vite config. Big thanks to Ben McCann for clearing up my misconceptions and helping me fix the package.json files.
Components
- Accordion
- A new component!
- Autocomplete
- A new component! Huge shoutout to Lorenzo Fiore who originally authored the component!
- Badge
- A new component!
- Common
- New announce function in the “internal” export.
- Paper
- New variants!
- Switch
- No longer needs
valueKeyprop. - Default color is now “primary”.
- No longer needs
SMUI 4 -> SMUI 5
Breaking Changes
- TypeScript!!! You don’t need to use TypeScript, but you do need to use the TypeScript preprocessor for Svelte.
- Events have been renamed from like “SMUI:component:sub-component:event” to “SMUIComponentSubComponent:event”.
- Elemental components (from @smui/common) should be imported as named imports from
@smui/common/elementsinstead, so that they have the right types. - The
/bareimport paths have been removed. (The default import path has been unstyled since v4.)
SMUI 4.0 -> SMUI 4.1
- Event modifiers have changed to use ”$” instead of ”:” (
on:click$capture={handler}), so that all events, even MDC events, can be bound with modifiers.- The old ”:” syntax will still work, it will just give a warning in the console.
SMUI 3 -> SMUI 4
Breaking Changes
Components no longer import styles from their “index.js” files. If you were using “/bare” before, you don’t need to anymore. If you were relying on styles being imported, you now need to use the “/styled” endpoint for components.
Check out the new smui-theme package. It can help you with your themes.
SMUI 3.0 -> SMUI 3.1
SMUI 3.1 migrated to upstream MDC 11.0 from 10.0: https://github.com/material-components/material-components-web/blob/master/CHANGELOG.md#1100-2021-04-15
You should update your MDC dependencies to 11.0 as well.
Breaking Changes
Theming, Sass
- MDC-Web chips trailing actions class changed.
- MDC-Web list classes changed.
New Features
Components
- Banner
- Add focus trap on the banner.
- Dialog
- New
fullscreenprop. - New
overslot.
- New
- Menu Surface
- New
maxHeightprop. - New
horizontallyCenteredOnViewportprop.
- New
- Slider
- Rounds values to correct decimal places based on
stepprop.
- Rounds values to correct decimal places based on
- Tooltip
- New
attachScrollHandlerandremoveScrollHandlerfunctions for adding additional scrollable elements to handle. Both accept a function.
- New
SMUI 2 -> SMUI 3
You will need to migrate to Dart Sass. node-sass is no longer supported, as it is deprecated and too old now.
npm un -D node-sass
npm i -D sass
SMUI 3 migrated to upstream MDC 10.0 from 4.0: https://github.com/material-components/material-components-web/blob/master/CHANGELOG.md#1000-2021-02-05
There are newly updated instructiong for using SMUI in Sapper.
Breaking Changes
Theming, Sass
- MDC-Web migrated to the “@use” syntax, so mixins, functions, and variables are namespaced by the “@use” statement now instead of a prefix.
- Theming has changed, so you’ll need to update your ”_smui-theme.scss” file. Follow this guide.
Components
- Chips
- You now need to use
let:chipon the set and pass it to the chip with{chip}. - Chips now export LeadingIcon, TrailingIcon, and TrailingAction, instead of Icon.
- Removed
selectedprop on Chip.selectedprop on Chips is now the only way to set the selected chip(s), and it/they should be identical to one/some of the entries inchips(pass objects by reference). - Don’t provide any
tabindexprops to any of the Chips, Texts, or the Set. They will manage their own tabindex. - On TrailingAction, use
icon$classto add classes to the icon element.
- You now need to use
- Data Table
numericprop on Cell should now also be set on Head Cells.
- Dialog
- Open state is now controled by an
openprop, instead ofopenandclosefunctions. There are alsoisOpenandsetOpenfunctions. - Lists should now be placed below
Contentelement, rather than being theContentcomponent. For selection from a list, use the newselectionprop on the dialog. - Slider dialogs are styled a bit differently. See the demo.
- Open state is now controled by an
- Icon Button
- No longer emit ‘MDCIconButtonToggle:change’ event without the
toggleprop. Instead, listen for click event.
- No longer emit ‘MDCIconButtonToggle:change’ event without the
- Linear Progress
- Removed
reversedprop.
- Removed
- List
radiolistandchecklistprops renamed toradioListandcheckList.
- Menu Surface
- Anchor action now takes
addClassandremoveClassinstead ofclassForward(like Ripple).
- Anchor action now takes
- Ripple
- Ripple’s options have changed considerably.
- Select
- This is almost completely rewritten. You will need to migrate code for it. Check out the demo page.
- Helper Text in no longer a component. Instead, a
svelte:fragmentwith text now goes inside the component in the “helper” slot. Its ID and ARIA attributes are set automatically. - Removed
withLeadingIconandselectedIndexprops. - You no longer need
withLeadingIcon. Instead, put Icon into the “leadingIcon” slot. - You should now set
requiredprop on the Select instead ofinput$required.
- Slider
displayMarkersprop renamed totickMarks.stepnow defaults to 1 (same as the range HTML input).
- Tab
- Removed
activeandfocusOnActivateprops. (No longer needed, since TabBar controls them.)
- Removed
- TabBar
- Removed
activeIndexprop.activeprop is now the only way to set the active tab, and it should be identical to one of the entries intabs(pass objects by reference).
- Removed
- Textfield
- This is almost completely rewritten. You will need to migrate code for it. Check out the demo page.
- Helper Text and Character Counter now go inside the component in the “helper” slot. Their IDs and ARIA attributes are set automatically.
- Character Counter in a
textareaTextfield goes in the “internalCounter” slot. - Removed
fullwidth,dense,withLeadingIcon, andwithTrailingIconprops. - You no longer need
withLeadingIconorwithTrailingIcon. Instead, put Icons into the “leadingIcon” and “trailingIcon” slots. - You should now set
requiredprop on the Textfield instead ofinput$required. - Manual setup now requires passing the sub-components into Textfield with
input,floatingLabel,lineRipple, andnotchedOutlineprops.
New Features.
Theming, Sass
- Paper
- New
paper-colormixin.
- New
- Switch
- New
colorprop.
- New
Components
- All components have a
getElementfunction that will return their top level DOM element. - All components now forward all events, and only listen for them if bounded.
- They can also take event modifiers with the ”:” syntax istead of ”|” (
on:click:capture={handler}).
New Components
- Banners
- Circular Progress
- Layout Grids
- Segmented Buttons
- Tooltips
- Touch Target Wrappers
New Features in Existing Components
- Chips
- New
nonInteractiveprop on Set. - New
shouldFocusPrimaryActionOnClickprop on Chip.
- New
- Common
- Icon now takes a
componentprop.
- Icon now takes a
- Data Table
- New
stickyHeaderprop. - New
columnIdprop on Cell (defaults to an automatic ID). - New
rowIdprop on Row (defaults to an automatic ID). - Pagination
- Progress Indicator
- Column Sort Buttons
- New
- Dialog
- New
selectionprop.
- New
- Drawer
- New
fixedprop (defaults to true). - New
isOpenfunction.
- New
- FAB
- New
touchprop.
- New
- Form Field
- New
noWrapprop.
- New
- Icon Button
- New
ariaLabelOnandariaLabelOffprops for toggle buttons.
- New
- Menu
- New
isOpenfunction. - New
setOpenfunction. - New
setDefaultFocusStatefunction.
- New
- Menu Surface
- New
fullWidthprop. - New
anchorMarginprop. - New
MDCMenuSurface:closingevent.
- New
- Select
- New
hiddenInputprop. - New
keyprop for using objects as options.
- New
- Slider
- New
range,start,endprops for range sliders. - New
valueToAriaValueTextFnprop for updating the ARIA value attribute.
- New
- TabBar
- New
tabScroller$alignprop.
- New
- Textfield
- New
prefixandsuffixprops. - New
validateOnValueChangeprop. - New
input$resizable={false}prop to disable textarea resizing. - New
helperLine$”$” props passed to the helper line.
- New
- Top App Bar
- New
scrollTargetprop.
- New
If you have trouble upgrading with these instructions, you can raise an issue on GitHub.
SMUI 1 -> SMUI 2
SMUI 2 migrated to upstream MDC 4.0 from 3.0: https://github.com/material-components/material-components-web/blob/master/CHANGELOG.md#400-2019-11-02-1
- Chips
- Text component is now required.
- Now use their own Text and Icon components. The common ones will not work.
- Icon no longer requires
trailingprop. That is the default. - Checkmark component is no longer required. It is added automatically.
- Menu and Menu Surface
- hoistMenuToBody function removed.
- Select
enchancedprop is removed. All selects are enhanced now.selectedprop on Option is no longer required and probably should not be used.- You now need to pass a class into
anchor$classandmenu$classwith a width value set.
- Button
- No longer has a
denseprop. Use the mixin from MDC.
- No longer has a