Ant Design StyleAnt Design Style
Quick Start
Best Practices
API Reference
Release Notes
⌘ K

Table of Contents

Migration Steps
1. Replace Entry Point
2. Replace Style Code
3. Adjust Hierarchy
4. Replace Less Variables with Tokens and JS Variables
New Component Writing Scheme
Basic Knowledge
Introduction
Quick Start to CSS in JS
Comparison of CSS in JS Writing Methods
Design Philosophy and Implementation Strategy
Quick Start
Writing Style
Theme Switching
Custom Theme
Advanced Usage
Babel Plugin
SSR Integration
Component Development
Integrated styled
🚧 Stylish Composite Styles
Performance Comparison of CSS-in-JS Libraries
Migrating from Less
Less Application Automated Migration
Manual Migration of Less Applications
Migrating Less Components
🚧 Compilation Differences Between CSS-in-JS and Less
PREV
Manual Migration of Less Applications
NEXT
🚧 Compilation Differences Between CSS-in-JS and Less

相关资源

Ant Design
Ant Design Pro
Ant Design Pro Components
Umi-React 应用开发框架
Dumi-组件/文档研发工具
qiankun-微前端框架

社区

Medium
Twitter
yuqueAnt Design 语雀专栏
Ant Design 知乎专栏
体验科技专栏
seeconfSEE Conf-SEE Conf-蚂蚁体验科技大会

帮助

GitHub
更新日志
讨论

more products更多产品

yuque语雀-知识创作与分享工具
AntVAntV-数据可视化解决方案
EggEgg-企业级 Node.js 框架
kitchenKitchen-Sketch 工具集
xtech蚂蚁体验科技
Copyright © 2022-2024
Made with ❤️ by 蚂蚁集团 - AFX & 数字科技
‌
‌
‌
‌

Migrating Component Code

The component demo below is from the ProCard's Static component in procomponents.

Migration Steps

1. Replace Entry Point

Change the style file from index.less to style.ts, and add the hooks const { styles } = useStyles() import. Combine the styles and the default container class in the JSX layer. This way, the JSX layer code is updated.

diff

2. Replace Style Code

Change the style code from less syntax to createStyles syntax. First, rename index.less to style.ts, then add the following at the top:

diff

Then place the original code inside the css function.

diff

3. Adjust Hierarchy

Since we use css`` to provide scope, the nested level styles need to be adjusted as follows:

diff

4. Replace Less Variables with Tokens and JS Variables

diff

The effect after migration is shown below. It can be seen that after a relatively low migration cost, the new component writing method already supports the ability to respond to themes by default and gains all the dynamic capabilities after cssinjs transformation.

New Component Writing Scheme

See: Component Development

12,312
inline
12,312
vertical
12,312
horizontal
12,312
inline
12,312
vertical
12,312
horizontal