logoAnt Design

⌘ K
  • 디자인
  • 개발
  • 컴포넌트
  • 블로그
  • 자료
5.21.3
  • React의 Ant Design
  • Ant Design of React
  • Ant Design of React
  • Changelog
    v5.21.3
  • 기본 사용법
    • 시작하기
    • Next.js에서 사용하기
      Updated
  • 如何使用
    • 在 create-react-app 中使用
    • 在 Vite 中使用
    • 在 Next.js 中使用
      Updated
    • 在 Umi 中使用
    • 在 Rsbuild 中使用
      New
    • 在 Farm 中使用
      New
    • 使用 Refine
      New
  • 迁移
    • 从 Less 变量到 Design Token
  • Basic Usage
    • Usage with create-react-app
    • Usage with Vite
    • Usage with Next.js
      Updated
    • Usage with Umi
    • Usage with Rsbuild
      New
    • Usage with Farm
      New
    • Usage with Refine
      New
  • 고급기능
    • 테마 커스터마이징
    • CSS 호환성
    • 서버 사이드 렌더링
    • 커스텀 날짜 라이브러리 사용하기
  • 进阶使用
    • 定制主题
    • 使用 CSS 变量
      New
  • Advanced
    • Customize Theme
    • CSS Variables
      New
    • Internationalization
    • Common Props
  • Migration
    • V4 to V5
    • Less variables to Component Token
  • 其他
    • 社区精选组件
    • 贡献指南
    • FAQ
  • Other
    • Third-Party Libraries
    • Contributing
    • FAQ

Customize Theme

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference
Work with Us

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

Ant Design allows you to customize our design tokens to satisfy UI diversity from business or brand requirements, including primary color, border radius, border color, etc.

In version 5.0, we provide a new way to customize themes. Different from the less and CSS variables of the 4.x version, with CSS-in-JS, the ability of theming has also been enhanced, including but not limited to:

  1. Switching theme dynamically;
  2. Multiple themes;
  3. Customizing theme variables for some components;
  4. ...

Basic Usage

In version 5.0 we call the smallest element that affects the theme Design Token. By modifying the Design Token, we can present various themes or components. You can pass theme to ConfigProvider to customize theme. After migrate to V5, theme of V5 will be applied by default.

WARNING

ConfigProvider will not take effect on static methods such as message.xxx, Modal.xxx, notification.xxx, because in these methods, antd will dynamically create new ones through ReactDOM.render React entities. Its context is not the same as the context of the current code, so context information cannot be obtained.

When you need context information (such as the content configured by ConfigProvider), you can use the Modal.useModal method to return the modal entity and the contextHolder node. Just insert it where you need to get the context, or you can use App Component to simplify the problem of usingModal and other methods that need to manually implant the contextHolder.

Customize Design Token

By modifying token property of theme, we can modify Design Token globally. Some tokens will affect other tokens. We call these tokens Seed Token.

Loading Demo...

Use Preset Algorithms

Themes with different styles can be quickly generated by modifying algorithm. Ant Design 5.0 provides three sets of preset algorithms by default:

  • default algorithm theme.defaultAlgorithm
  • dark algorithm theme.darkAlgorithm
  • compact algorithm theme.compactAlgorithm

You can switch algorithms by modifying the algorithm property of theme in ConfigProvider.

Loading Demo...

Customize Component Token

In addition to Design Token, each component will also have its own Component Token to achieve style customization capabilities for components, and different components will not affect each other. Similarly, other Design Token of components can also be overridden in this way.

Algorithm

By default, all component tokens can only override global token and will not be derived based on Seed Token.

In version >= 5.8.0, component tokens support the algorithm property, which can be used to enable algorithm or pass in other algorithms.

Loading Demo...

Disable Motion

antd has built-in interaction animations to make enterprise-level pages more detailed. In some extreme scenarios, it may affect the performance of page interaction. If you need to turn off the animation, try setting motion of token to false:

Loading Demo...

Advanced

Switch Themes Dynamically

In v5, dynamically switching themes is very simple for users, you can dynamically switch themes at any time through the theme property of ConfigProvider without any additional configuration.

Loading Demo...

Nested Theme

By nesting ConfigProvider you can apply local theme to some parts of your page. Design Tokens that have not been changed in the child theme will inherit the parent theme.

Loading Demo...

Consume Design Token

If you want to consume the Design Token under the current theme, we provide useToken hook to get Design Token.

Loading Demo...

Static consume (e.g. less)

When you need token out of React life cycle, you can use static function to get them:

import { theme } from 'antd';
const { getDesignToken } = theme;
const globalToken = getDesignToken();

Same as ConfigProvider, getDesignToken could also accept a config object as theme:

import type { ThemeConfig } from 'antd';
import { theme } from 'antd';
import { createRoot } from 'react-dom/client';
const { getDesignToken, useToken } = theme;
const config: ThemeConfig = {
token: {
colorPrimary: '#1890ff',
},
};
// By static function
const globalToken = getDesignToken(config);
// By hook
const App = () => {
const { token } = useToken();
return null;
};
// Example for rendering
createRoot(document.getElementById('#app')).render(
<ConfigProvider theme={config}>
<App />
</ConfigProvider>,
);

If you want to use in preprocess style framework like less, use less-loader for injection:

{
loader: "less-loader",
options: {
lessOptions: {
modifyVars: mapToken,
},
},
}

Compatible package provide convert function to transform to v4 less variable. Read this for detail.

Theme editor

We provide tools to help users debug themes: Theme Editor

You can use this tool to freely modify Design Token to meet your theme expectations.

Design Token

In Design Token, we provide a three-layer structure that is more suitable for the design, and disassemble the Design Token into three parts: Seed Token, Map Token and Alias Token. These three groups of Tokens are not simple groupings, but a three-layer derivation relationship. Map Tokens are derived from Seed Tokens, and Alias Tokens are derived from Map Tokens. In most cases, using Seed Tokens is sufficient for custom themes. But if you need a higher degree of theme customization, you need to understand the life cycle of Design Token in antd.

Life of Design Token

token

Seed Token

Seed Token means the origin of all design intent. For example, we can change the theme color by changing colorPrimary, and the algorithm inside antd will automatically calculate and apply a series of corresponding colors according to the Seed Token:

const theme = {
token: {
colorPrimary: '#1890ff',
},
};

Map Token

Map Token is a gradient variable derived from Seed. It is recommended to implement custom Map Token through theme.algorithm, which can ensure the gradient relationship between Map Tokens. It can also be overridden by theme.token to modify the value of some map tokens individually.

const theme = {
token: {
colorPrimaryBg: '#e6f7ff',
},
};

Alias Token

Alias Token is used to control the style of some common components in batches, which is basically a Map Token alias, or a specially processed Map Token.

const theme = {
token: {
colorLink: '#1890ff',
},
};

Algorithm

The basic algorithm is used to expand the Seed Token into a Map Token, such as calculating a gradient color palette from a basic color, or calculating rounded corners of various sizes from a basic rounded corner. Algorithms can be used alone or in any combination, for example, dark and compact algorithms can be combined to get a dark and compact theme.

import { theme } from 'antd';
const { darkAlgorithm, compactAlgorithm } = theme;
const theme = {
algorithm: [darkAlgorithm, compactAlgorithm],
};

API

Theme

PropertyDescriptionTypeDefault
tokenModify Design TokenAliasToken-
inheritInherit theme configured in upper ConfigProviderbooleantrue
algorithmModify the algorithms of theme(token: SeedToken) => MapToken | ((token: SeedToken) => MapToken)[]defaultAlgorithm
componentsModify Component Token and Alias Token applied to componentsComponentsConfig-
cssVarToggle CSS Variables, refer CSS Variablesboolean | { prefix?: string; key?: string }false
hashedComponent class Hash value, refer CSS Variablesbooleantrue

ComponentsConfig

PropertyDescriptionTypeDefault
Component (Can be any antd Component name like Button)Modify Component Token or override Component used Alias TokenComponentToken & AliasToken & { algorithm: boolean | (token: SeedToken) => MapToken | ((token: SeedToken) => MapToken)[]}-

algorithm of component is false by default, which means tokens of component will only override global token. When it is set with true, the algorithm will be the same as global. You can also pass algorithm or Array of algorithm, and it will override algorithm of global.

SeedToken

토큰 이름설명타입기본값
borderRadius기본 컴포넌트의 모서리 크기, 예: 버튼, 입력 창, 카드 등.number6
colorBgBase배경색 그라데이션을 파생시키는 기본 변수를 사용하여, v5에서는 배경색의 파생 알고리즘을 추가하여 명확한 그라데이션의 배경색을 생성할 수 있는 그라데이션 변수를 도출할 수 있습니다. 하지만 코드 내에서 해당 Seed Token을 직접 사용하지 마세요!string#fff
colorError오류 Button, 오류 Result 컴포넌트 등 작업 실패의 시각적 요소를 나타내는 데 사용됩니다.string#ff4d4f
colorInfoAlert, Tag, Progress 등과 같은 컴포넌트에서 사용하는 토큰 시퀀스의 작업 정보를 나타내는 데 사용됩니다. 해당 그룹의 그라데이션 변수가 사용됩니다.string#1677ff
colorLink控制超链接的颜色。string#1677ff
colorPrimary브랜드 색상은 제품의 특성과 커뮤니케이션을 반영하는 가장 직접적인 시각적 요소 중 하나입니다. 브랜드 색상을 선택하면, 자동으로 전체 색상 팔레트를 생성하고 효과적인 디자인 의미를 부여합니다.string#1677ff
colorSuccess작업 성공을 나타내는 토큰 시퀀스입니다. Result, Progress 등의 컴포넌트에서 이 맵 토큰을 사용합니다.string#52c41a
colorTextBase用于派生文本色梯度的基础变量,v5 中我们添加了一层文本色的派生算法可以产出梯度明确的文本色的梯度变量。但请不要在代码中直接使用该 Seed Token !string#000
colorWarning경고를 나타내는 토큰 시퀀스입니다. Notification, Alert 등의 경고성 컴포넌트나 Input 등의 제어 컴포넌트에서 이 맵 토큰을 사용합니다.string#faad14
controlHeightAnt Design에서 버튼과 입력 창 등 기본 컨트롤의 높이number32
fontFamilyAnt Design의 글꼴 모음은 시스템의 기본 인터페이스 글꼴을 우선시하며, 친근하고 안정적이며 전문적인 특성을 반영하여 다양한 플랫폼과 브라우저에서 글꼴의 가독성과 가독성을 유지하기 위해 화면 디스플레이에 적합한 대체 글꼴 라이브러리 세트를 제공합니다.string-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontFamilyCode代码字体,用于 Typography 内的 code、pre 和 kbd 类型的元素string'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace
fontSize디자인 시스템에서 가장 널리 사용되는 글꼴 크기로, 텍스트 그라데이션이 파생됩니다.number14
lineType컴포넌트의 테두리, 분할선 등의 스타일을 제어하는 데 사용되며, 기본값은 실선입니다.stringsolid
lineWidth컴포넌트의 테두리, 구분선 등의 두너를 제어하는 데 사용됩니다.number1
motion用于配置动画效果,为 `false` 时则关闭动画booleantrue
motionBasenumber0
motionEaseInBack预设动效曲率stringcubic-bezier(0.71, -0.46, 0.88, 0.6)
motionEaseInOut미리 설정된 애니메이션 곡률.stringcubic-bezier(0.645, 0.045, 0.355, 1)
motionEaseInOutCirc모션 커브를 미리 설정합니다.stringcubic-bezier(0.78, 0.14, 0.15, 0.86)
motionEaseInQuint모션 커브를 미리 설정합니다.stringcubic-bezier(0.755, 0.05, 0.855, 0.06)
motionEaseOut预设动效曲率stringcubic-bezier(0.215, 0.61, 0.355, 1)
motionEaseOutBack기본 동작 곡선입니다.stringcubic-bezier(0.12, 0.4, 0.29, 1.46)
motionEaseOutCirc모션 커브를 미리 설정합니다.stringcubic-bezier(0.08, 0.82, 0.17, 1)
motionEaseOutQuint모션 커브를 미리 설정합니다.stringcubic-bezier(0.23, 1, 0.32, 1)
motionUnit用于控制动画时长的变化单位number0.1
opacityImage控制图片不透明度number1
sizePopupArrow화살표 컴포넌트의 크기number16
sizeStep用于控制组件尺寸的基础步长,尺寸步长结合尺寸变化单位,就可以派生各种尺寸梯度。通过调整步长即可得到不同的布局模式,例如 V5 紧凑模式下的尺寸步长为 2number4
sizeUnit用于控制组件尺寸的变化单位,在 Ant Design 中我们的基础单位为 4 ,便于更加细致地控制尺寸梯度number4
wireframe用于将组件的视觉效果变为线框化,如果需要使用 V4 的效果,需要开启配置项booleanfalse
zIndexBase所有组件的基础 Z 轴值,用于一些悬浮类的组件的可以基于该值 Z 轴控制层级,例如 BackTop、 Affix 等number0
zIndexPopupBase浮层类组件的基础 Z 轴值,用于一些悬浮类的组件的可以基于该值 Z 轴控制层级,例如 FloatButton、 Affix、Modal 等number1000

MapToken

Inherit all SeedToken properties

토큰 이름설명타입기본값
borderRadiusLGCard, Modal 및 다른 컴포넌트와 같이 테두리 반경이 큰 일부 컴포넌트에 사용되는 LG 크기 테두리 반경입니다.number8
borderRadiusOuter外部圆角number4
borderRadiusSMButton, Input, Select 및 작은 크기의 다른 입력 컴포넌트와 같이 작은 크기의 컴포넌트에 사용되는 SM 크기 테두리 반경입니다.number4
borderRadiusXSSegmented, Arrow 및 테두리 반경이 작은 다른 컴포넌트와 같이 테두리 반경이 작은 일부 컴포넌트에 사용되는 XS 크기 테두리 반경입니다.number2
colorBgBlur控制毛玻璃容器的背景色,通常为透明色。stringtransparent
colorBgContainer컨테이너 배경 색상, 예: 기본 버튼, 입력 상자, 등. `colorBgElevated`와 혼동을 주의하세요.string#ffffff
colorBgElevated팝업 레이어의 컨테이너 배경색으로, 다크 모드에서 이 토큰의 색상 값은 `colorBgContainer`보다 약간 밝습니다. 예 : modal, pop-up, menu 등string#ffffff
colorBgLayout该色用于页面整体布局的背景色,只有需要在页面中处于 B1 的视觉层级时才会使用该 token,其他用法都是错误的string#f5f5f5
colorBgMask浮层的背景蒙层颜色,用于遮罩浮层下面的内容,Modal、Drawer 等组件的蒙层使用的是该 tokenstringrgba(0, 0, 0, 0.45)
colorBgSolid实心的背景颜色,目前只用在默认实心按钮背景色上。stringrgb(0, 0, 0)
colorBgSolidActive实心的背景颜色激活态,目前只用在默认实心按钮的 active 效果。stringrgba(0, 0, 0, 0.95)
colorBgSolidHover实心的背景颜色悬浮态,目前只用在默认实心按钮的 hover 效果。stringrgba(0, 0, 0, 0.75)
colorBgSpotlight该色用于引起用户强烈关注注意的背景色,目前只用在 Tooltip 的背景色上。stringrgba(0, 0, 0, 0.85)
colorBorder기본적으로 사용되는 테두리 색상은 서로 다른 요소를 구분하는 데 사용됩니다. 예: 폼의 구분선, 카드의 구분선 등.string#d9d9d9
colorBorderSecondary比默认使用的边框色要浅一级,此颜色和 colorSplit 的颜色一致。使用的是实色。string#f0f0f0
colorErrorActive错误色的深色激活态string#d9363e
colorErrorBg오류 배경색.string#fff2f0
colorErrorBgActive错误色的浅色背景色激活态string#ffccc7
colorErrorBgFilledHover错误色的浅色填充背景色悬浮态,目前只用在危险填充按钮的 hover 效果。string#ffdfdc
colorErrorBgHover오류 배경색의 호버 상태.string#fff1f0
colorErrorBorder错误色的描边色string#ffccc7
colorErrorBorderHover错误色的描边色悬浮态string#ffa39e
colorErrorHover오류 색상의 Hover 상태입니다.string#ff7875
colorErrorText错误色的文本默认态string#ff4d4f
colorErrorTextActive错误色的文本激活态string#d9363e
colorErrorTextHover错误色的文本悬浮态string#ff7875
colorFill最深的填充色,用于拉开与二、三级填充色的区分度,目前只用在 Slider 的 hover 效果。stringrgba(0, 0, 0, 0.15)
colorFillQuaternary最弱一级的填充色,适用于不易引起注意的色块,例如斑马纹、区分边界的色块等。stringrgba(0, 0, 0, 0.02)
colorFillSecondary2차 채우기 색상은 Rate, Skeleton 등의 요소의 형체를 더 명확하게 윤곽을 그릴 수 있습니다. 또한 Table 등에서 3차 채우기 색상의 호버 상태로 사용할 수도 있습니다.stringrgba(0, 0, 0, 0.06)
colorFillTertiary3차 채우기 색상은 Slider, Segmented 등의 요소 형체를 윤곽 그리는 데 사용됩니다. 특별한 강조가 필요하지 않다면 3차 채우기 색상을 기본 채우기 색상으로 사용하는 것을 권장합니다.stringrgba(0, 0, 0, 0.04)
colorInfoActive信息色的深色激活态。string#0958d9
colorInfoBg信息色的浅色背景颜色。string#e6f4ff
colorInfoBgHover信息色的浅色背景色悬浮态。string#bae0ff
colorInfoBorder信息色的描边色。string#91caff
colorInfoBorderHover信息色的描边色悬浮态。string#69b1ff
colorInfoHover信息色的深色悬浮态。string#69b1ff
colorInfoText信息色的文本默认态。string#1677ff
colorInfoTextActive信息色的文本激活态。string#0958d9
colorInfoTextHover信息色的文本悬浮态。string#4096ff
colorLinkActive控制超链接被点击时的颜色。string#0958d9
colorLinkHover控制超链接悬浮时的颜色。string#69b1ff
colorPrimaryActive主色梯度下的深色激活态。string#0958d9
colorPrimaryBg主色浅色背景颜色,一般用于视觉层级较弱的选中状态。string#e6f4ff
colorPrimaryBgHover与主色浅色背景颜色相对应的悬浮态颜色。string#bae0ff
colorPrimaryBorderSlider와 같은 컴포넌트의 획에 사용되는 주 색상 그라데이션 아래의 획 색상입니다.string#91caff
colorPrimaryBorderHover主色梯度下的描边用色的悬浮态,Slider 、Button 等组件的描边 Hover 时会使用。string#69b1ff
colorPrimaryHover주요 색상의 그라데이션의 호버 상태.string#4096ff
colorPrimaryText主色梯度下的文本颜色。string#1677ff
colorPrimaryTextActive主色梯度下的文本激活态。string#0958d9
colorPrimaryTextHover主色梯度下的文本悬浮态。string#4096ff
colorSuccessActive成功色的深色激活态string#389e0d
colorSuccessBg成功色的浅色背景颜色,用于 Tag 和 Alert 的成功态背景色string#f6ffed
colorSuccessBgHover成功色浅色背景颜色,一般用于视觉层级较弱的选中状态,不过 antd 目前没有使用到该 tokenstring#d9f7be
colorSuccessBorder成功色的描边色,用于 Tag 和 Alert 的成功态描边色string#b7eb8f
colorSuccessBorderHover成功色的描边色悬浮态string#95de64
colorSuccessHover成功色的深色悬浮态string#95de64
colorSuccessText成功色的文本默认态string#52c41a
colorSuccessTextActive成功色的文本激活态string#389e0d
colorSuccessTextHover成功色的文本悬浮态string#73d13d
colorTextW3C 표준을 준수하는 기본 텍스트 색상으로, 이 색상은 가장 어두운 중립적인 색상이기도 합니다.stringrgba(0, 0, 0, 0.88)
colorTextQuaternary4차 텍스트 색상은 가장 연한 텍스트 색상으로, 예를 들어 폼의 입력 힌트 텍스트, 비활성화된 텍스트 등이 해당됩니다.stringrgba(0, 0, 0, 0.25)
colorTextSecondary作为第二梯度的文本色,一般用在不那么需要强化文本颜色的场景,例如 Label 文本、Menu 的文本选中态等场景。stringrgba(0, 0, 0, 0.65)
colorTextTertiary3차 텍스트 색상은 주로 설명 텍스트에 사용됩니다. 예: 폼의 보충 설명 텍스트, 목록의 설명 텍스트 등 장면stringrgba(0, 0, 0, 0.45)
colorWarningActive警戒色的深色激活态string#d48806
colorWarningBg경고 배경색string#fffbe6
colorWarningBgHover경고 배경색의 호버 상태string#fff1b8
colorWarningBorder警戒色的描边色string#ffe58f
colorWarningBorderHover警戒色的描边色悬浮态string#ffd666
colorWarningHover경고 색상의 호버 상태string#ffd666
colorWarningText警戒色的文本默认态string#faad14
colorWarningTextActive警戒色的文本激活态string#d48806
colorWarningTextHover警戒色的文本悬浮态string#ffc53d
colorWhite不随主题变化的纯白色string#fff
controlHeightLGLG 컴포넌트 높이number40
controlHeightSMSM 컴포넌트 높이number24
controlHeightXSXS 컴포넌트 높이number16
fontSizeHeading1H1 标签所使用的字号number38
fontSizeHeading2h2 标签所使用的字号number30
fontSizeHeading3h3 标签使用的字号number24
fontSizeHeading4h4 标签使用的字号number20
fontSizeHeading5h5 标签使用的字号number16
fontSizeLGLG 폰트 크기number16
fontSizeSM작은 글꼴 크기number12
fontSizeXL超大号字体大小number20
lineHeight텍스트의 행간number1.5714285714285714
lineHeightHeading1H1 标签所使用的行高number1.2105263157894737
lineHeightHeading2h2 标签所使用的行高number1.2666666666666666
lineHeightHeading3h3 태그의 줄 높이number1.3333333333333333
lineHeightHeading4h4 标签所使用的行高number1.4
lineHeightHeading5h5 标签所使用的行高number1.5
lineHeightLG大型文本行高number1.5
lineHeightSM小型文本行高number1.6666666666666667
lineWidthBold描边类组件的默认线宽,如 Button、Input、Select 等输入类控件。number2
motionDurationFast动效播放速度,快速。用于小型元素动画交互string0.1s
motionDurationMid모션 속도, 중간 속도. 중간 요소 애니메이션 상호 작용에 사용됩니다.string0.2s
motionDurationSlow동작 재생 속도, 느린 속도입니다. 대형 요소의 패널 애니메이션 상호작용에 사용됩니다.string0.3s
size默认尺寸number16
sizeLGnumber24
sizeMDnumber20
sizeMSnumber16
sizeSMnumber12
sizeXLnumber32
sizeXSnumber8
sizeXXLnumber48
sizeXXSnumber4

AliasToken

Inherit all SeedToken and MapToken properties

토큰 이름설명타입기본값
boxShadow控制元素阴影样式。string 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)
boxShadowSecondary요소의 보조 상자 그림자 스타일을 제어합니다.string 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)
boxShadowTertiary控制元素三级盒子阴影样式。string 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)
colorBgContainerDisabled비활성화된 컨테이너 배경색stringrgba(0, 0, 0, 0.04)
colorBgTextActive控制文本在激活状态下的背景色。stringrgba(0, 0, 0, 0.15)
colorBgTextHover控制文本在悬停状态下的背景色。stringrgba(0, 0, 0, 0.06)
colorBorderBg요소의 배경 테두리 색상을 제어합니다.string#ffffff
colorErrorOutline입력 컴포넌트 오류 상태에서 외곽선 색상을 제어합니다.stringrgba(255, 38, 5, 0.06)
colorFillAlter요소의 대체할 배경색을 제어합니다.stringrgba(0, 0, 0, 0.02)
colorFillContent控制内容区域的背景色。stringrgba(0, 0, 0, 0.06)
colorFillContentHover控制内容区域背景色在鼠标悬停时的样式。stringrgba(0, 0, 0, 0.15)
colorHighlight控制页面元素高亮时的颜色。string#ff4d4f
colorIcon약한 조작 아이콘의 색상을 제어합니다. 예: allowClear 또는 Alert 닫기 버튼. *stringrgba(0, 0, 0, 0.45)
colorIconHover약한 조작 아이콘의 호버 상태에서 색상을 제어합니다. 예: allowClear 또는 Alert 닫기 버튼.stringrgba(0, 0, 0, 0.88)
colorSplit구분선의 색상으로 사용되며, 이 색상은 colorBorderSecondary와 동일하지만 투명도가 있습니다.stringrgba(5, 5, 5, 0.06)
colorTextDescription텍스트 설명의 글꼴 색상을 제어합니다.stringrgba(0, 0, 0, 0.45)
colorTextDisabled비활성화 상태에서의 글자 색상을 제어하다。stringrgba(0, 0, 0, 0.25)
colorTextHeading헤딩의 텍스트 색상을 제어합니다.stringrgba(0, 0, 0, 0.88)
colorTextLabel텍스트 레이블의 글꼴 색상을 제어합니다.stringrgba(0, 0, 0, 0.65)
colorTextLightSolidPrimary Button 컴포넌트의 텍스트와 같이 배경색으로 텍스트의 하이라이트 색상을 제어합니다.string#fff
colorTextPlaceholder비활성화 상태에서의 글자 색상을 제어하다stringrgba(0, 0, 0, 0.25)
colorWarningOutline입력 컴포넌트 경고 상태에서 외곽선 색상을 제어합니다stringrgba(255, 215, 5, 0.1)
controlInteractiveSize控制组件的交互大小。number16
controlItemBgActive활성화 시 제어 컴포넌트 요소의 배경색을 제어합니다.string#e6f4ff
controlItemBgActiveDisabled控制组件项在禁用状态下的激活背景颜色。stringrgba(0, 0, 0, 0.15)
controlItemBgActiveHover마우스를 올리고 활성화할 때 제어 컴포넌트 요소의 배경색을 제어합니다.string#bae0ff
controlItemBgHover마우스를 올릴 때 제어 컴포넌트 요소의 배경색을 제어합니다.stringrgba(0, 0, 0, 0.04)
controlOutline입력 컴포넌트의 외곽선 색상을 제어합니다.stringrgba(5, 145, 255, 0.1)
controlOutlineWidth입력 컴포넌트의 외곽선 너비를 제어합니다.number2
controlPaddingHorizontal요소의 가로 안쪽 여백을 제어합니다.number12
controlPaddingHorizontalSMSM 크기 요소의 수평 패딩을 제어합니다.number8
fontSizeIconSelect, Cascader 등에서 작업 아이콘의 글꼴 크기를 제어합니다. 일반적으로 fontSizeSM과 동일합니다.number12
fontWeightStrong控制标题类组件(如 h1、h2、h3)或选中项的字体粗细。number600
lineWidthFocus컴포넌트가 포커스 상태에 있을 때 선의 너비를 제어합니다.number3
linkDecoration控制链接文本的装饰样式。undefined | TextDecoration<string | number>none
linkFocusDecoration控制链接聚焦时文本的装饰样式。undefined | TextDecoration<string | number>none
linkHoverDecoration控制链接鼠标悬浮时文本的装饰样式。undefined | TextDecoration<string | number>none
margin控制元素外边距,中等尺寸。number16
marginLG控制元素外边距,大尺寸。number24
marginMD控制元素外边距,中大尺寸。number20
marginSM控制元素外边距,中小尺寸。number12
marginXL控制元素外边距,超大尺寸。number32
marginXS요소의 여백을 작은 크기로 제어합니다.number8
marginXXL控制元素外边距,最大尺寸。number48
marginXXS요소의 여백을 가장 작은 크기로 제어합니다.number4
opacityLoading控制加载状态的透明度。number0.65
padding요소의 안쪽 여백을 제어합니다.number16
paddingContentHorizontal控制内容元素水平内间距。number16
paddingContentHorizontalLG控制内容元素水平内间距,适用于大屏幕设备。number24
paddingContentHorizontalSM控制内容元素水平内间距,适用于小屏幕设备。number16
paddingContentVertical控制内容元素垂直内间距。number12
paddingContentVerticalLG控制内容元素垂直内间距,适用于大屏幕设备。number16
paddingContentVerticalSM控制内容元素垂直内间距,适用于小屏幕设备。number8
paddingLG요소의 큰 패딩을 제어합니다.number24
paddingMD控制元素的中等内间距。number20
paddingSM요소의 작은 내부 여백을 제어합니다.number12
paddingXL요소의 매우 큰 패딩을 제어합니다.number32
paddingXS요소의 매우 작은 안쪽 여백을 제어합니다.number8
paddingXXS요소의 아주 매우 작은 안쪽 여백을 제어합니다.number4
screenLG控制大屏幕的屏幕宽度。number992
screenLGMax控制大屏幕的最大宽度。number1199
screenLGMin控制大屏幕的最小宽度。number992
screenMD控制中等屏幕的屏幕宽度。number768
screenMDMax控制中等屏幕的最大宽度。number991
screenMDMin控制中等屏幕的最小宽度。number768
screenSM控制小屏幕的屏幕宽度。number576
screenSMMax控制小屏幕的最大宽度。number767
screenSMMin控制小屏幕的最小宽度。number576
screenXL控制超大屏幕的屏幕宽度。number1200
screenXLMax控制超大屏幕的最大宽度。number1599
screenXLMin控制超大屏幕的最小宽度。number1200
screenXS控制超小屏幕的屏幕宽度。number480
screenXSMax控制超小屏幕的最大宽度。number575
screenXSMin控制超小屏幕的最小宽度。number480
screenXXL控制超超大屏幕的屏幕宽度。number1600
screenXXLMin控制超超大屏幕的最小宽度。number1600

FAQ

Why component re-mounted when theme changed from undefined to some object or to undefined?

In ConfigProvider, we pass context through DesignTokenContext. When theme is undefined, a layer of Provider will not be set, so React VirtualDOM structure changes from scratch or from existence to nothing, causing components to be re-mounted. Solution: Replace undefined with an empty object {}.

import { Button, ConfigProvider, Space } from 'antd';
import React from 'react';

const App: React.FC = () => (
  <ConfigProvider
    theme={{
      token: {
        // Seed Token
        colorPrimary: '#00b96b',
        borderRadius: 2,

        // Alias Token
        colorBgContainer: '#f6ffed',
      },
    }}
  >
    <Space>
      <Button type="primary">Primary</Button>
      <Button>Default</Button>
    </Space>
  </ConfigProvider>
);

export default App;
Open on CodeSandboxOpen Sandbox
import React from 'react';
import { Button, ConfigProvider, Input, Space, theme } from 'antd';

const App: React.FC = () => (
  <ConfigProvider
    theme={{
      // 1. Use dark algorithm
      algorithm: theme.darkAlgorithm,

      // 2. Combine dark algorithm and compact algorithm
      // algorithm: [theme.darkAlgorithm, theme.compactAlgorithm],
    }}
  >
    <Space>
      <Input placeholder="Please Input" />
      <Button type="primary">Submit</Button>
    </Space>
  </ConfigProvider>
);

export default App;
Open on CodeSandboxOpen Sandbox
import React from 'react';
import { ConfigProvider, Button, Space, Input, Divider } from 'antd';

const App: React.FC = () => (
  <>
    <ConfigProvider
      theme={{
        components: {
          Button: {
            colorPrimary: '#00b96b',
            algorithm: true, // Enable algorithm
          },
          Input: {
            colorPrimary: '#eb2f96',
            algorithm: true, // Enable algorithm
          }
        },
      }}
    >
      <Space>
        <div style={{ fontSize: 14 }}>Enable algorithm: </div>
        <Input placeholder="Please Input" />
        <Button type="primary">Submit</Button>
      </Space>
    </ConfigProvider>
    <Divider />
    <ConfigProvider
      theme={{
        components: {
          Button: {
            colorPrimary: '#00b96b',
          },
          Input: {
            colorPrimary: '#eb2f96',
          }
        },
      }}
    >
      <Space>
        <div style={{ fontSize: 14 }}>Disable algorithm: </div>
        <Input placeholder="Please Input" />
        <Button type="primary">Submit</Button>
      </Space>
    </ConfigProvider>
  </>
);

export default App;
Open on CodeSandboxOpen Sandbox
import React from 'react';
import { Checkbox, Col, ConfigProvider, Flex, Radio, Row, Switch } from 'antd';

const App: React.FC = () => {
  const [checked, setChecked] = React.useState<boolean>(false);
  const timerRef = React.useRef<ReturnType<typeof setInterval>>();
  React.useEffect(() => {
    timerRef.current = setInterval(() => {
      setChecked((prev) => !prev);
    }, 500);
    return () => {
      if (timerRef.current) {
        clearInterval(timerRef.current);
      }
    };
  }, []);

  const nodes = (
    <Flex gap="small">
      <Checkbox checked={checked}>Checkbox</Checkbox>
      <Radio checked={checked}>Radio</Radio>
      <Switch checked={checked} />
    </Flex>
  );

  return (
    <Row gutter={[24, 24]}>
      <Col span={24}>{nodes}</Col>
      <Col span={24}>
        <ConfigProvider theme={{ token: { motion: false } }}>{nodes}</ConfigProvider>
      </Col>
    </Row>
  );
};

export default App;
Open on CodeSandboxOpen Sandbox
import { Button, ConfigProvider, Space, Input, ColorPicker, Divider } from 'antd';
import React from 'react';

const App: React.FC = () => {
  const [primary, setPrimary] = React.useState('#1677ff');

  return (
    <>
      <ColorPicker showText value={primary} onChange={(color) => setPrimary(color.toHexString())} />
      <Divider />
      <ConfigProvider
        theme={{
          token: {
            colorPrimary: primary,
          },
        }}
      >
        <Space>
          <Input placeholder="Please Input" />
          <Button type="primary">Submit</Button>
        </Space>
      </ConfigProvider>
    </>
  );
}

export default App;
Open on CodeSandboxOpen Sandbox
import React from 'react';
import { Button, ConfigProvider, Space } from 'antd';

const App: React.FC = () => (
  <ConfigProvider
    theme={{
      token: {
        colorPrimary: '#1677ff',
      },
    }}
  >
    <Space>
      <Button type="primary">Theme 1</Button>
      <ConfigProvider
        theme={{
          token: {
            colorPrimary: '#00b96b',
          },
        }}
      >
        <Button type="primary">Theme 2</Button>
      </ConfigProvider>
    </Space>
  </ConfigProvider>
);

export default App;
Open on CodeSandboxOpen Sandbox
import React from 'react';
import { Button, theme } from 'antd';

const { useToken } = theme;

const App: React.FC = () => {
  const { token } = useToken();

  return (
    <div
      style={{
        backgroundColor: token.colorPrimaryBg,
        padding: token.padding,
        borderRadius: token.borderRadius,
        color: token.colorPrimaryText,
        fontSize: token.fontSize,
      }}
    >
      Consume Design Token
    </div>
  );
};

export default App;
Open on CodeSandboxOpen Sandbox