Skip to content

Migrating from Material UI

Edit on GitHub

The first step is to install @volvo-cars/css and @volvo-cars/edls-css. During the transition period, you can use both MUI and EDLS components in the same project.

The migration process varies depending on the type of component.


Examples: Box, Stack, Grid, Typography, Button

The design system provides utility classes as alternatives to these MUI components. If you’re not familiar with utility classes, read the CSS architecture page first.

For general layouts and Grid components, follow the layout guidelines.

For Box, Stack, Typography, and Button, we provide codemods.

The codemods perform the following steps:

  • Replace JSX markup to use HTML elements instead of MUI components.
  • Replace sx attributes with style attributes.
  • Transform margin, padding, and flex properties into Volvo CSS classes, removing them from the style object.
  • Transform variant attributes into Volvo CSS classes.

If any properties are not supported by Volvo CSS, they are kept in the style object.

  1. Install the tooling

    Terminal window
    yarn add jscodeshift @volvo-cars/edls-cli -D
  2. Run the codemods

    Replace . with the path to the folder you want to migrate. We recommend creating one PR per component to keep changes reviewable.

    Terminal window
    npx jscodeshift --transform ./node_modules/@volvo-cars/edls-cli/codemods/box-transform.cjs --parser tsx --ignore-pattern="*.ts" --ignore-pattern="*.d.ts" --ignore-pattern="node_modules" .
    npx jscodeshift --transform ./node_modules/@volvo-cars/edls-cli/codemods/stack-transform.cjs --parser tsx --ignore-pattern="*.ts" --ignore-pattern="*.d.ts" --ignore-pattern="node_modules" .
    npx jscodeshift --transform ./node_modules/@volvo-cars/edls-cli/codemods/button-transform.cjs --parser tsx --ignore-pattern="*.ts" --ignore-pattern="*.d.ts" --ignore-pattern="node_modules" .
    npx jscodeshift --transform ./node_modules/@volvo-cars/edls-cli/codemods/typography-transform.cjs --parser tsx --ignore-pattern="*.ts" --ignore-pattern="*.d.ts" --ignore-pattern="node_modules" .
  3. Remove MUI imports. This is not included in the codemods due to the different ways MUI components can be imported. A find-and-replace in your editor will do the trick.

  4. Run Prettier and ESLint to format the migrated code.


Material UIEDLS Alternative
ButtonButton
IconIcon
IconButtonIconButton
InputTextInput
TextAreaTextArea
CheckboxCheckbox
RadioRadio
SelectSelect
SwitchSwitch
SliderRangeSlider
DialogDialog
SidebarSheet
TooltipTooltip
BreadcrumbsBreadcrumbs
AccordionAccordion
DataGridTable
TablePaginationTablePagination
PaginationPagePagination
DatePickerDropdownCalendar
DateRangePickerDropdownCalendarRange
MultiSelectDropdownMultiSelect
FilterSelectDropdownSelect
SkeletonSkeleton
ProgressSpinner
SnackbarWork in progress

Refer to the component documentation for usage details and examples of each alternative.