基于 Ant Design V5 Token System 构建的业务级 css-in-js
解决方案。
基于 emotion 二次封装。
- Ant Design Token System:
- 自定义主题:
- 收敛而确定的用法:与 Css Modules 基本一致的
- 超强扩展性:
推荐使用 pnpm
安装
pnpm i antd-style -S
import { css, useTheme } from 'antd-style';
export const useStyle = () => {
const token = useTheme();
return css`
color: ${token.colorPrimary};
`;
};
import { styled } from 'antd-style';
const Card = styled.div<{ primary?: boolean }>`
border-radius: ${(p) => p.theme.borderRadiusLG}px;
padding: ${(p) => p.theme.paddingLG}px;
background: ${(p) => (p.primary ? p.theme.colorPrimary : p.theme.colorBgContainer)};
color: ${(p) => (p.primary ? p.theme.colorTextLightSolid : p.theme.colorText)};
`;
const App = () => {
return (
<div>
<Card>普通卡片</Card>
<Card primary>强调卡片</Card>
</div>
);
};
详情:CHANGELOG