Ant Design 5.0 is Released!
Published: 2022-11-21 02:58:34

### Introduction
At the end of September, we released v5 alpha version. After 2 months of adjustment, API has gradually stabilized. Thanks to the community for the valuable suggestions and contributions, it is the power of the community that enables Ant Design to complete a lot of renovation work in a short period of time. Here we will explain some major updates of v5. Of course, you can also go directly to the [changelog](https://ant.design/changelog) page to view the complete update content.

Same as the previous major version release. We will switch v4 from the master branch to the `4.x-stable` branch into maintenance. **v4 will continue to be maintained for 1 year, and patches will still be released for bugs, but no new Feature Requests will be accepted after that. The deadline is the end of 2023.** Original official website was migrated to [https://4x.ant.design/.](https://4x.ant.design/.)

### Design upgrade
In terms of design, we have added 4 types of new components and 4+ variant components according to our business practices and the voice of the community. These components have been scrutinized to ensure their versatility and extensibility. We hope they will bring you a good use experience. At the same time, we have opened up some heavy assets that have been used internally for a long time to help you serve more business scenarios.

![image](https://user-images.githubusercontent.com/5378891/202630055-4d445628-b6b9-4a74-bd88-7968afd4f9a3.png)


In addition we have fully upgraded the components with default styles. Adhering to the core of happy work, we have upgraded the system vision in three directions: "more focus", "distraction", and "relaxation". It involves the optimization and adjustment of multiple global styles such as main colors, rounded corners, text levels, and interactive feedback. In addition, we have also de-linearized the navigation framework and almost all components. These changes bring a brand-new feeling, and also easier to use in the specific use process. Of course you can easily customize your own theme with one click according to the style algorithm and configuration tools we provide in 5.0 if you have different aesthetics and demands for style themes.

![image](https://user-images.githubusercontent.com/5378891/202630191-2129ac2f-58ab-409c-8867-7ff54cf2151b.png)

![image](https://user-images.githubusercontent.com/5378891/202630221-586b3b17-1e6b-40cd-9366-5ccd1a26a969.png)



Finally, we are experimenting with a theme package called "Happy Work", which contains emotional enhancement features. When users use it in a specific scenario, there will be rich but restrained animations, bringing users a little "happy feeling". We hope this is a start, calling on industry design to pay more attention to enterprise-level products, and inject more emotion into cold enterprise-level products to care for our users. The happy work theme pack will be launched after the press conference, so stay tuned~

### Brand new Design Token Model

![image](https://user-images.githubusercontent.com/5378891/202630302-16898714-bc1b-4afe-a039-27e1191d9fa2.png)


In v4, we create lots of less variables to support theme customization capabilities. However, expect color palettes, there is no corresponding algorithm for other fonts, line heights, and spacing. In v5, we transformed all tokens can be derived based on Seed + Algorithm. The new Design Token Model supports multi-algorithm pipelines, which greatly reduces developer expansion costs. You can choose an existing algorithm and add your own extended algorithm (of course, you can also write a complete set of algorithms) to generate a complete set of Design Tokens:

![image](https://user-images.githubusercontent.com/5378891/202630322-ba8e290d-40c7-4fb2-bd52-0398324d3c55.png)


### CSS-in-JS Dynmaic Theme
In the past we have tried to provide dynamic theming capabilities through CSS Variables. After a period of exploration, we found that maintenance cost of the intermediate variables becomes non-negligible with the complexity of the design system increases. Therefore, CSS Variables in v4 stayed in the dynamic theme color and did not further provide the dynamic ability of dark colors and other tokens. In v5, we face dynamic themes again with the need of flexibility.

At the beginning of v5, we spent a few months comparing the popular dynamic theming solutions: CSS Variables and CSS-in-JS. CSS-in-JS doesn't need to maintain intermediate variables, but has more runtime overhead (if you're not familiar with this, please read [Why We're Breaking Up with CSS-in-JS](https://dev.to/srmagura/why-were-breaking-up-wiht-css-in-js-4g9b)). We prefer the latter in terms of maintenance costs, but we don't want to compromise the user experience. So after a series of attempts, we developed a CSS-in-JS library `@ant-design/cssinjs` for the component level. It achieves higher cache efficiency by sacrificing dynamism, thus reducing the performance penalty at runtime.

With the dynamic theme capability, you can adjust and nest themes arbitrarily through ConfigProvider:
```tsx
<ConfigProvider theme={{ token: { colorPrimary: 'red' }}}>
  <ConfigProvider theme={{ token: { colorPrimary: 'blue' }}}>
    <MyApp />
  </ConfigProvider>
</ConfigProvider>
```

Even adjusted for a single component:
```tsx
<ConfigProvider theme={{
  components: {
    Button: { colorText: 'red' },
  },
}}>
  <MyApp />
</ConfigProvider>
```

Code is boring? You can experience examples directly on our homepage:

![theme](https://user-images.githubusercontent.com/5378891/202630397-c806d705-59a9-4f00-8237-7de604ec6d54.gif)


The new CSS-in-JS solution natively supports Tree Shaking, and in v5 you no longer need to use `babel-plugin-import` to remove unused styles. It will automatically load styles on demand.

### More components
New FloatButton component is used for global functionality on the website, the original BackTop will be its child component:

![image](https://user-images.githubusercontent.com/5378891/202630440-3babbf22-cc55-4027-83f8-eb312f794da5.png)


New Tour component is added to guide users through product features:

![image](https://user-images.githubusercontent.com/5378891/202630471-f12ac35f-66c4-4a58-9273-68a19caf7206.png)


Additionally, we provide some variants of components for inline use:

![image](https://user-images.githubusercontent.com/5378891/202630606-010493e2-cb4f-4abf-bf28-b35a7637c6a2.png)


### Compatibility tweaks

#### Browser minimum version adjustment
In June of this year, IE announced that it would stop maintenance, so the compatibility adjustment of Ant Design v5 was upgraded from IE 11 to Edge, and the rest of the modern browsers remained unchanged. All IE compatibility style code will be removed. At this point, we can combine RTL and LTR styles through [CSS Logical Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties) to further reduce maintenance costs.


#### Replace Moment.js with Day.js
Moment.js transitioned to [Legacy Project](https://momentjs.com/docs/#/-project-status/) in 2020. Considering that switching the date library would lead to Break Change, we chose to continue using Moment.js during v4 until the end of v4. With v5, we switched to the more lightweight Day.js. In addition to the smaller package size, Day.js also brings immutable capabilities.

Of course, if you want your project to still use Moment.js after an upgrade, you can replace it with the `@ant-design/moment-webpack-plugin`.


#### API non-Break adjustments
During Ant Design's 7-year development, some APIs were forked. This leads to additional memory costs for developers, and it also makes it difficult for us to choose when adding new APIs. Originally, we planned to organize and merge a series of APIs. Similar to the v3 upgrade to v4, we will prompt developers to migrate APIs in the current version, and remove obsolete APIs in v5. However, [after community communication](https://github.com/ant-design/ant-design/issues/36609), we decided to change the plan as follows: **Each major version will only adjust a small number of APIs, and the original deprecated APIs will continue to be compatible in the new version, and will be deferred until the next major version to remove.** This time we changed the following parts, and v5 will be fully compatible with the original writing:

- Popup like components `open` and `visible` are unified to `open` to match to HTML Spec.
- `dropdownClassName` and `popupClassName` are unified to `popupClassName` for better semantics.
- Structural syntactic sugar (e.g. <Select.Option /> ) is replaced with data-driven in preparation for performance optimization.
- Deprecate static methods (such as `Message.error`), and recommend application layer encapsulation to support React 18 concurrent mode.


#### Components removement
v5 will remove the Comment and PageHeader components, and BackTop will become a FloatButton sub-component. Since the Comment component itself provides no actual capabilities other than styling, developers still need extra work to implement the commenting functionality. Also, we decided to remove it from v5 due to not many actual usage scenarios, but you can still find it in the compatibility pack. The PageHeader component also required some development work to make it work, so we moved it into ProComponents and used it with ProLayout to provide real interactivity.

### Upgrade Guide
As mentioned in Compatibility Adjustments, since v5 will not make API Break Changes, you can try migrating via our codemod tool. For Moment.js, you can use the `@ant-design/moment-webpack-plugin` to replace. If your project relies on antd's less files, please refer to our migration documentation for compatibility via less-loader. For detailed documentation, please [click here](https://next.ant.design/docs/react/migration-v5).

### Future plan
In the future we plan to provide more components, some of them are already on the agenda, such as WaterMark, QrCode, ColorPicker. We've heard the voices for Table performance, and we plan to provide virtual scrolling capabilities for the display state, which will natively support fixed column capabilities. Also, since in v4 we have converged the structural syntactic sugar into data-driven properties, we have better opportunities to optimize performance, including but not limited to Menu, Table, Steps, Collapse, Tabs, Dropdown, and more.

On the design side, we will update the official site to provide more component-level design guidelines, which will be continuously updated by the design team. We have written a lot of articles in the Chinese community in the past, and **we hope to take this opportunity to provide English versions** of the articles so that international developers and designers can read them together. let us wait and see.


### Write at the end
After 7 years, Ant Design has become an ecologically rich community. During the period, the help of community is inseparable. From Ant Design v4, a large number of community volunteers participated to v5, and most of the functions were completed by community. It is you who made Ant Design v5 complete the research and development work so quickly, and you made open source beautiful. Thank you everyone!

![image](https://user-images.githubusercontent.com/5378891/202630647-70e7f69a-0445-47c4-9dd5-6c9935dbf2b9.png)


- [iamkun](https://github.com/iamkun)
- [zombiej](https://github.com/zombiej)
- [afc163](https://github.com/afc163)
- [madccc](https://github.com/madccc)
- [PeachScript](https://github.com/PeachScript)
- [vagusX](https://github.com/vagusX)
- [LongHaoo](https://github.com/LongHaoo)
- [xrkffgg](https://github.com/xrkffgg)
- [chenshuai2144](https://github.com/chenshuai2144)
- [lushevol](https://github.com/lushevol)
- [Wxh16144](https://github.com/Wxh16144)
- [kunl](https://github.com/kunl)
- [cncolder](https://github.com/cncolder)
- [c0dedance](https://github.com/c0dedance)
- [jrr997](https://github.com/jrr997)
- [Dunqing](https://github.com/Dunqing)
- [JarvisArt](https://github.com/JarvisArt)
- [zqran](https://github.com/zqran)
- [TrickyPi](https://github.com/TrickyPi)
- [li-jia-nan](https://github.com/li-jia-nan)
- [heiyu4585](https://github.com/heiyu4585)
- [foryuki](https://github.com/foryuki)
- [chunsch](https://github.com/chunsch)
- [yykoypj](https://github.com/yykoypj)
- [cl1107](https://github.com/cl1107)
- [poyiding](https://github.com/poyiding)
- [dancerphil](https://github.com/dancerphil)
- [miracles1919](https://github.com/miracles1919)
- [zpc7](https://github.com/zpc7)
- [shuaijiumei](https://github.com/shuaijiumei)
- [lzm0x219](https://github.com/lzm0x219)
- [LuZhenJie1999](https://github.com/LuZhenJie1999)
- [BesideWithYou](https://github.com/BesideWithYou)
- [shezhangzhang](https://github.com/shezhangzhang)