# @chapanda/style-preset-antd

> chapanda style preset

Latest version **1.4.17-beta.3** (published 2026-06-29) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @chapanda/style-preset-antd
pnpm add @chapanda/style-preset-antd
yarn add @chapanda/style-preset-antd
bun add @chapanda/style-preset-antd
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.4.17-beta.3 |
| Published | 2026-06-29 |
| First published | 2024-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 118.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | baiwusanyu-c |
| Maintainers | baiwusanyu, black927 |
| Keywords | typescript, javascript, utils, vue, vue3, vite, react, web component |

## Links

- npm: https://www.npmjs.com/package/@chapanda/style-preset-antd
- Repository: https://github.com/baiwusanyu-c/chapanda-style-preset
- Issues: https://github.com/baiwusanyu-c/chapanda-style-preset/issues
- npm.io page: https://npm.io/package/@chapanda/style-preset-antd

## Dependencies (4)

- [antd](https://npm.io/package/antd.md) ^6.0.0
- [@ant-design/colors](https://npm.io/package/@ant-design/colors.md) ^8.0.1
- [@chapanda/style-preset-base](https://npm.io/package/@chapanda/style-preset-base.md) ^1.4.17-beta.3
- [@chapanda/style-preset-utils](https://npm.io/package/@chapanda/style-preset-utils.md) ^1.4.17-beta.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.4.17-beta.3 (latest) — 2026-06-29
- 1.4.17-beta.1 — 2026-06-29
- 1.4.16 — 2025-08-07
- 1.4.15 — 2025-08-07
- 1.4.14 — 2025-07-21
- 1.4.13 — 2025-07-09
- 1.4.12 — 2025-07-09
- 1.4.11 — 2025-06-26
- 1.4.10 — 2025-06-24
- 1.4.9 — 2025-01-15
- 1.4.8 — 2025-01-15
- 1.4.7 — 2025-01-15
- 1.4.6 — 2024-12-13
- 1.4.6-beta.1 — 2024-12-13
- 1.4.4 — 2024-12-12
- … 21 more at https://npm.io/package/@chapanda/style-preset-antd/versions

## README

# @chapanda/style-preset-antd

基于中心规范基础结合 `antd` 的组件库样式预设.

## 使用

1. 首先通过 `antd` 提供的 `ConfigProvider`，通过使用 `genChaPandaAntdTheme` 方法设置主题变量。

```typescript jsx
import React from 'react';
import { Button, Flex } from 'antd';
import { genChaPandaAntdTheme } from '@chapanda/style-preset-antd'
function App() {
  return (
    <ConfigProvider theme={genChaPandaAntdTheme()}>
      <Flex gap="small" wrap>
        <Button type="primary">Primary Button</Button>
        <Button>Default Button</Button>
        <Button type="dashed">Dashed Button</Button>
        <Button type="text">Text Button</Button>
        <Button type="link">Link Button</Button>
      </Flex>
    </ConfigProvider>
  )
}
```

2. 入口文件 `main.tsx` 引入 `scss` 样式文件（单靠 `antd` 提供的 `token` 定制主题，无法完全满足样式需求）

```typescript jsx
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import '@chapanda/style-preset-antd/theme'
createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <App />
  </StrictMode>,
)

```

## API

### genChaPandaAntdTheme

```typescript jsx
 declare function genChaPandaAntdTheme(theme?: ThemeConfig): {
  // ...
  // 省略返回类型
}
```
`genChaPandaAntdTheme` 用于生成符合中心规范的结合 `antd` 的组件库变量 `token`, 它接收一个可选的参数 `theme`,
当传入 `theme` 时，它的将和默认的 `chapanda` 预设合并，如果存在相同 `token`，
将覆盖 `chapanda` 预设的 `token`，最终返回 `antd` 的 `theme` 对象传递给 `ConfigProvider` 组件


## 参考
关于全局样式（布局对齐、字体、颜色变量等）请阅读 `@chapanda/style-preset-base` 文档

---
_Source: https://npm.io/package/@chapanda/style-preset-antd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
