|
| 1 | +--- |
| 2 | +title: Why you should migrate to Material UI v5 today |
| 3 | +description: We have completely revamped our Migration guide to reduce friction when upgrading to v5. Get started now! |
| 4 | +date: 2022-06-15T00:00:00.000Z |
| 5 | +authors: ['samuelsycamore'] |
| 6 | +card: true |
| 7 | +tags: ['MUI Core'] |
| 8 | +--- |
| 9 | + |
| 10 | +Are you still using Material UI v4 in 2022? |
| 11 | + |
| 12 | +What are you thinking?! 😛 Don't get left behind! |
| 13 | + |
| 14 | +We [released v5 in late 2021](/blog/mui-core-v5/), and since then, we've seen [a steady migration of users](https://npm-stat.com/charts.html?package=@mui/material,@material-ui/core) over to the new packages. |
| 15 | +This is exciting for us, because we're super proud of all the improvements that were shipped with v5. |
| 16 | + |
| 17 | +But it seems as though a fair share of users are still hesitant to make the jump. |
| 18 | +This could be because v5 contains many breaking changes from v4, so the migration can be a large undertaking. |
| 19 | + |
| 20 | +That's why we've completely revamped our [v4 -> v5 migration guide](https://mui.com/material-ui/migration/migration-v4/)—to help reduce the amount of friction you might encounter when updating to v5. |
| 21 | + |
| 22 | +We hope it helps! |
| 23 | +Be sure to check out [the updated migration guide](https://mui.com/material-ui/migration/migration-v4/) in the Material UI docs. |
| 24 | + |
| 25 | +## Why you should upgrade to v5 |
| 26 | + |
| 27 | +Here are the top 5 reasons why you should upgrade to v5 ASAP. |
| 28 | + |
| 29 | +### 1. React 18 support |
| 30 | + |
| 31 | +Material UI v5 is the only version that fully supports [React 18](https://reactjs.org/blog/2022/03/29/react-v18.html), so you'll need to update if you want to take advantage of the latest and greatest React features. |
| 32 | + |
| 33 | +### 2. New style engine |
| 34 | + |
| 35 | +One of the biggest changes in v5 is the replacement of JSS with [Emotion](https://emotion.sh/docs/introduction) as the default style engine. |
| 36 | +This offers significant advancements in performance when it comes to dynamic styles, and we also believe that it leads to a much more enjoyable developer experience. |
| 37 | + |
| 38 | +Emotion unlocks many new customization options that developers had been requesting for years, such as custom style utility props, color variants, and custom theme variants. |
| 39 | +Check out [this RFC on GitHub](https://github.com/mui/material-ui/issues/22342) for details about this change. |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +Keep in mind that the new style engine is 100% incrementally adoptable: you can use JSS and Emotion together in the same app while migrating your components over. |
| 44 | + |
| 45 | +### 3. Better customization tools |
| 46 | + |
| 47 | +Material UI v5 introduces the `sx` prop, which opens up a whole new realm of possibility for applying custom styles. |
| 48 | +Now you can apply style rules to individual components without needing to involve the `styled()` API, which would be overkill when dealing with one-off styles. |
| 49 | + |
| 50 | +The `sx` prop lets you work with a superset of CSS, making it very intuitive to pick up and start using if you're already comfortable with CSS. |
| 51 | + |
| 52 | +```tsx |
| 53 | +import * as React from 'react'; |
| 54 | +import Box from '@mui/material/Box'; |
| 55 | + |
| 56 | +export default function BoxSx() { |
| 57 | + return ( |
| 58 | + <Box |
| 59 | + sx={{ |
| 60 | + width: 300, |
| 61 | + height: 300, |
| 62 | + backgroundColor: 'primary.dark', |
| 63 | + '&:hover': { |
| 64 | + backgroundColor: 'primary.main', |
| 65 | + opacity: [0.9, 0.8, 0.7], |
| 66 | + }, |
| 67 | + }} |
| 68 | + /> |
| 69 | + ); |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### 4. IntelliSense prop descriptions |
| 74 | + |
| 75 | +All prop descriptions are now written in TypeScript, which means that you can access details about the usage of a given prop right inside of your IDE—no need to seek out the official documentation to find this information. |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +### 5. Upcoming CSS variables support |
| 80 | + |
| 81 | +[CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) will help us solve a lot of customization issues in the future. |
| 82 | +One of them is the dark mode flashing issue that has been requested for a long time. |
| 83 | + |
| 84 | +More importantly, this feature is opt-in if you are using Material UI v5! |
| 85 | +You can check out the progress on this effort [in this GitHub issue](https://github.com/mui/material-ui/issues/32049). |
| 86 | + |
| 87 | +## Upgrade now |
| 88 | + |
| 89 | +What are you waiting for? |
| 90 | +Jump into the [newly revised migration documention](https://mui.com/material-ui/migration/migration-v4/) and get started today. |
| 91 | + |
| 92 | +Let us know if you have any questions along the way! |
0 commit comments