logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.3.2
  • Ant Design of React
  • Getting Started
  • Real project with Umi
  • Use in create-react-app
  • Use in TypeScript
  • CSS Compatible
  • Customize Theme
  • Use custom date library
  • V4 to V5
  • Third-Party Libraries
  • Internationalization
  • FAQ
  • Contributing
  • Change Log
Customize theme with ConfigProvider
Customize Design Token
Use Preset Algorithms
Customize Component Token
Other Ways to Use Dynamic Themes
Switch Themes Dynamically
Local Theme
Consume Design Token
Static consume (e.g. less)
Advanced
Life Cycle of Design Token
Seed Token
Map Token
Alias Token
Algorithm
Legacy Browser Compatible
Server Side Render (SSR)
Shadow DOM Usage
API
Theme
OverrideToken
SeedToken
MapToken
AliasToken
StyleProvider
How to Debug your Theme
Theme Presets
FAQ
Why component re-mounted when theme changed from undefined to some object or to undefined?

Customize Theme

CSS CompatibleUse custom date library

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
yuqueAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTechMore Products

yuqueYuQue-Document Collaboration Platform
AntVAntV-Data Visualization
EggEgg-Enterprise Node.js Framework
kitchenKitchen-Sketch Toolkit
xtechAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community

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 component;
  4. ...

Customize theme with ConfigProvider

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.

Customize Design Token

You can pass theme to ConfigProvider to customize theme. After migrate to V5, theme of V5 will be applied by default. Here's a simple example:

import { Button, ConfigProvider } from 'antd';
import React from 'react';
const App: React.FC = () => (
<ConfigProvider
theme={{
token: {
colorPrimary: '#00b96b',
},
}}
>
<Button />
</ConfigProvider>
);
export default App;

You will get a theme with primary color #00b96b. And we can see the change in Button:

themed button

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, which are default algorithm theme.defaultAlgorithm, dark algorithm theme.darkAlgorithm and compact algorithm theme.compactAlgorithm. You can switch algorithms by modifying the algorithm property of theme in ConfigProvider.

import { Button, ConfigProvider, theme } from 'antd';
import React from 'react';
const App: React.FC = () => (
<ConfigProvider
theme={{
algorithm: theme.darkAlgorithm,
}}
>
<Button />
</ConfigProvider>
);
export default App;

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.

import { Checkbox, ConfigProvider, Radio } from 'antd';
import React from 'react';
const App: React.FC = () => (
<ConfigProvider
theme={{
components: {
Radio: {
colorPrimary: '#00b96b',
},
},
}}
>
<Radio>Radio</Radio>
<Checkbox>Checkbox</Checkbox>
</ConfigProvider>
);
export default App;

In this way, we changed the primary color of Radio to #00b96b, and Checkbox is not affected.

component token

Notice: 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.

Other Ways to Use Dynamic Themes

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.

Local 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.

import { Button, ConfigProvider } from 'antd';
import React from 'react';
const App: React.FC = () => (
<ConfigProvider
theme={{
token: {
colorPrimary: '#1677ff',
},
}}
>
<Button />
<ConfigProvider
theme={{
token: {
colorPrimary: '#1890ff',
},
}}
>
<Button />
</ConfigProvider>
</ConfigProvider>
);
export default App;

Consume Design Token

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

import { Button, theme } from 'antd';
import React from 'react';
const { useToken } = theme;
const App: React.FC = () => {
const { token } = useToken();
return <Button style={{ backgroundColor: token.colorPrimary }}>Button</Button>;
};
export default App;

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 { defaultAlgorithm, defaultSeed } = theme;
const mapToken = defaultAlgorithm(defaultSeed);

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.

Advanced

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 Cycle 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],
};

Legacy Browser Compatible

Please ref to CSS Compatible.

Server Side Render (SSR)

There are two options for server-side rendering styles, each with advantages and disadvantages:

  • Inline mode: there is no need to request additional style files during rendering. The advantage is to reduce additional network requests. The disadvantage is that the HTML volume will increase and the speed of the first screen rendering will be affected. Relevant discussion: #39891
  • Whole export: The antd component is pre-baked and styled as a css file to be introduced in the page. The advantage is that when opening any page, the same set of css files will be reused just like the traditional css scheme to hit the cache. The disadvantage is that if there are multiple themes in the page, additional baking is required

Inline mode

Use @ant-design/cssinjs to extract style:

import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';
import { renderToString } from 'react-dom/server';
export default () => {
// SSR Render
const cache = createCache();
const html = renderToString(
<StyleProvider cache={cache}>
<MyApp />
</StyleProvider>,
);
// Grab style from cache
const styleText = extractStyle(cache);
// Mix with style
return `
<!DOCTYPE html>
<html>
<head>
${styleText}
</head>
<body>
<div id="root">${html}</div>
</body>
</html>
`;
};

Whole export

If you want to detach a style file into a css file, try the following schemes:

  1. Installation dependency
npm install ts-node tslib --save-dev
  1. Add tsconfig.node.json
{
"compilerOptions": {
"strictNullChecks": true,
"module": "NodeNext",
"jsx": "react",
"esModuleInterop": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
  1. Add scripts/genAntdCss.tsx
// scripts/genAntdCss.tsx
import { extractStyle } from '@ant-design/static-style-extract';
import fs from 'fs';
const outputPath = './public/antd.min.css';
const css = extractStyle();
fs.writeFileSync(outputPath, css);

If you want to use mixed themes or custom themes, you can use the following script:

import { extractStyle } from '@ant-design/static-style-extract';
import { ConfigProvider } from 'antd';
import fs from 'fs';
import React from 'react';
const outputPath = './public/antd.min.css';
const testGreenColor = '#008000';
const testRedColor = '#ff0000';
const css = extractStyle((node) => (
<>
<ConfigProvider
theme={{
token: {
colorBgBase: testGreenColor,
},
}}
>
{node}
</ConfigProvider>
<ConfigProvider
theme={{
token: {
colorPrimary: testGreenColor,
},
}}
>
<ConfigProvider
theme={{
token: {
colorBgBase: testRedColor,
},
}}
>
{node}
</ConfigProvider>
</ConfigProvider>
</>
));
fs.writeFileSync(outputPath, css);

You can choose to execute this script before starting the development command or before compiling. Running this script will generate a full antd.min.css file directly in the specified directory of the current project (e.g. public).

Take Next.js for example(example):

// package.json
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"predev": "ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx",
"prebuild": "ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx"
}
}

Then, you just need to import this file into the pages/_app.tsx file:

import { StyleProvider } from '@ant-design/cssinjs';
import type { AppProps } from 'next/app';
import '../public/antd.min.css';
import '../styles/globals.css'; // add this line
export default function App({ Component, pageProps }: AppProps) {
return (
<StyleProvider hashPriority="high">
<Component {...pageProps} />
</StyleProvider>
);
}

Custom theme

If you're using a custom theme for your project, try baking in the following ways:

import { extractStyle } from '@ant-design/static-style-extract';
import { ConfigProvider } from 'antd';
const cssText = extractStyle((node) => (
<ConfigProvider
theme={{
token: {
colorPrimary: 'red',
},
}}
>
{node}
</ConfigProvider>
));

Mixed theme

If you're using a mixed theme for your project, try baking in the following ways:

import { extractStyle } from '@ant-design/static-style-extract';
import { ConfigProvider } from 'antd';
const cssText = extractStyle((node) => (
<>
<ConfigProvider
theme={{
token: {
colorBgBase: 'green ',
},
}}
>
{node}
</ConfigProvider>
<ConfigProvider
theme={{
token: {
colorPrimary: 'blue',
},
}}
>
<ConfigProvider
theme={{
token: {
colorBgBase: 'red ',
},
}}
>
{node}
</ConfigProvider>
</ConfigProvider>
</>
));

More about static-style-extract, see static-style-extract.

Shadow DOM Usage

Since <style /> tag insertion is different from normal DOM in Shadow DOM scenario, you need to use StyleProvider of @ant-design/cssinjs to configure the container property to set the insertion position:

import { StyleProvider } from '@ant-design/cssinjs';
import { createRoot } from 'react-dom/client';
const shadowRoot = someEle.attachShadow({ mode: 'open' });
const container = document.createElement('div');
shadowRoot.appendChild(container);
const root = createRoot(container);
root.render(
<StyleProvider container={shadowRoot}>
<MyApp />
</StyleProvider>,
);

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 componentsOverrideToken-

OverrideToken

PropertyDescriptionTypeDefault
Component (Can be any antd Component name like Button)Modify Component Token or override Component used Alias TokenComponentToken & AliasToken-

SeedToken

Token NameDescriptionTypeDefault Value
borderRadiusBorder radius of base componentsnumber6
colorBgBaseUsed to derive the base variable of the background color gradient. In v5, we added a layer of background color derivation algorithm to produce map token of background color. But PLEASE DO NOT USE this Seed Token directly in the code!string#fff
colorErrorUsed to represent the visual elements of the operation failure, such as the error Button, error Result component, etc.string#ff4d4f
colorInfoUsed to represent the operation information of the Token sequence, such as Alert, Tag, Progress, and other components use these map tokens.string#1677ff
colorPrimaryBrand color is one of the most direct visual elements to reflect the characteristics and communication of the product. After you have selected the brand color, we will automatically generate a complete color palette and assign it effective design semantics.string#1677ff
colorSuccessUsed to represent the token sequence of operation success, such as Result, Progress and other components will use these map tokens.string#52c41a
colorTextBaseUsed to derive the base variable of the text color gradient. In v5, we added a layer of text color derivation algorithm to produce gradient variables of text color gradient. But please do not use this Seed Token directly in the code!string#000
colorWarningUsed to represent the warning map token, such as Notification, Alert, etc. Alert or Control component(like Input) will use these map tokens.string#faad14
controlHeightThe height of the basic controls such as buttons and input boxes in Ant Designnumber32
fontFamilystring-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'
fontFamilyCodestring'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace
fontSizeThe most widely used font size in the design system, from which the text gradient will be derived.number14
lineTypeBorder style of base componentsstringsolid
lineWidthBorder width of base componentsnumber1
motionBasenumber0
motionEaseInBackPreset motion curve.stringcubic-bezier(0.71, -0.46, 0.88, 0.6)
motionEaseInOutPreset motion curve.stringcubic-bezier(0.645, 0.045, 0.355, 1)
motionEaseInOutCircPreset motion curve.stringcubic-bezier(0.78, 0.14, 0.15, 0.86)
motionEaseInQuintPreset motion curve.stringcubic-bezier(0.755, 0.05, 0.855, 0.06)
motionEaseOutPreset motion curve.stringcubic-bezier(0.215, 0.61, 0.355, 1)
motionEaseOutBackPreset motion curve.stringcubic-bezier(0.12, 0.4, 0.29, 1.46)
motionEaseOutCircPreset motion curve.stringcubic-bezier(0.08, 0.82, 0.17, 1)
motionEaseOutQuintPreset motion curve.stringcubic-bezier(0.23, 1, 0.32, 1)
motionUnitThe unit of animation duration changenumber0.1
opacityImagenumber1
sizePopupArrownumber16
sizeStepThe base step of size change, the size step combined with the size change unit, can derive various size steps. By adjusting the step, you can get different layout modes, such as the size step of the compact mode of V5 is 2number4
sizeUnitThe unit of size change, in Ant Design, our base unit is 4, which is more fine-grained control of the size stepnumber4
wireframebooleanfalse
zIndexBaseThe base Z axis value of all components, which can be used to control the level of some floating components based on the Z axis value, such as BackTop, Affix, etc.number0
zIndexPopupBaseBase zIndex of component like FloatButton, Affix which can be cover by large popupnumber1000

MapToken

Inherit all SeedToken properties

Token NameDescriptionTypeDefault Value
borderRadiusLGLG size border radius, used in some large border radius components, such as Card, Modal and other components.number8
borderRadiusOuternumber4
borderRadiusSMSM size border radius, used in small size components, such as Button, Input, Select and other input components in small sizenumber4
borderRadiusXSXS size border radius, used in some small border radius components, such as Segmented, Arrow and other components with small border radius.number2
colorBgContainerContainer background color, e.g: default button, input box, etc. Be sure not to confuse this with `colorBgElevated`.string#ffffff
colorBgElevatedstring#ffffff
colorBgLayoutstring#f5f5f5
colorBgMaskThe background color of the mask, used to cover the content below the mask, Modal, Drawer and other components use this tokenstringrgba(0, 0, 0, 0.45)
colorBgSpotlightstringrgba(0, 0, 0, 0.85)
colorBorderDefault border color, used to separate different elements, such as: form separator, card separator, etc.string#d9d9d9
colorBorderSecondarySlightly lighter than the default border color, this color is the same as `colorSplit`. Solid color is used.string#f0f0f0
colorErrorActiveThe active state of the error color.string#d9363e
colorErrorBgThe background color of the error state.string#fff2f0
colorErrorBgHoverThe hover state background color of the error state.string#fff1f0
colorErrorBorderThe border color of the error state.string#ffccc7
colorErrorBorderHoverThe hover state border color of the error state.string#ffa39e
colorErrorHoverThe hover state of the error color.string#ff7875
colorErrorTextThe default state of the text in the error color.string#ff4d4f
colorErrorTextActiveThe active state of the text in the error color.string#d9363e
colorErrorTextHoverThe hover state of the text in the error color.string#ff7875
colorFillstringrgba(0, 0, 0, 0.15)
colorFillQuaternarystringrgba(0, 0, 0, 0.02)
colorFillSecondarystringrgba(0, 0, 0, 0.06)
colorFillTertiarystringrgba(0, 0, 0, 0.04)
colorInfoActiveActive state of dark color of information color.string#0958d9
colorInfoBgLight background color of information color.string#e6f4ff
colorInfoBgHoverHover state of light background color of information color.string#bae0ff
colorInfoBorderBorder color of information color.string#91caff
colorInfoBorderHoverHover state of border color of information color.string#69b1ff
colorInfoHoverHover state of dark color of information color.string#69b1ff
colorInfoTextDefault state of text color of information color.string#1677ff
colorInfoTextActiveActive state of text color of information color.string#0958d9
colorInfoTextHoverHover state of text color of information color.string#4096ff
colorPrimaryActiveDark active state under the main color gradient.string#0958d9
colorPrimaryBgLight background color of primary color, usually used for weak visual level selection state.string#e6f4ff
colorPrimaryBgHoverThe hover state color corresponding to the light background color of the primary color.string#bae0ff
colorPrimaryBorderThe stroke color under the main color gradient, used on the stroke of components such as Slider.string#91caff
colorPrimaryBorderHoverThe hover state of the stroke color under the main color gradient, which will be used when the stroke Hover of components such as Slider and Button.string#69b1ff
colorPrimaryHoverHover state under the main color gradient.string#4096ff
colorPrimaryTextText color under the main color gradient.string#1677ff
colorPrimaryTextActiveActive state of text color under the main color gradient.string#0958d9
colorPrimaryTextHoverHover state of text color under the main color gradient.string#4096ff
colorSuccessActiveActive state color of dark success colorstring#389e0d
colorSuccessBgLight background color of success color, used for Tag and Alert success state background colorstring#f6ffed
colorSuccessBgHoverLight background color of success color, but antd does not use this token currentlystring#d9f7be
colorSuccessBorderBorder color of success color, used for Tag and Alert success state border colorstring#b7eb8f
colorSuccessBorderHoverHover state color of success color borderstring#95de64
colorSuccessHoverHover state color of dark success colorstring#95de64
colorSuccessTextDefault state color of success color textstring#52c41a
colorSuccessTextActiveActive state color of success color textstring#389e0d
colorSuccessTextHoverHover state color of success color textstring#73d13d
colorTextDefault text color which comply with W3C standards, and this color is also the darkest neutral color.stringrgba(0, 0, 0, 0.88)
colorTextQuaternarystringrgba(0, 0, 0, 0.25)
colorTextSecondarystringrgba(0, 0, 0, 0.65)
colorTextTertiarystringrgba(0, 0, 0, 0.45)
colorWarningActiveThe active state of the warning color.string#d48806
colorWarningBgThe background color of the warning state.string#fffbe6
colorWarningBgHoverThe hover state background color of the warning state.string#fff1b8
colorWarningBorderThe border color of the warning state.string#ffe58f
colorWarningBorderHoverThe hover state border color of the warning state.string#ffd666
colorWarningHoverThe hover state of the warning color.string#ffd666
colorWarningTextThe default state of the text in the warning color.string#faad14
colorWarningTextActiveThe active state of the text in the warning color.string#d48806
colorWarningTextHoverThe hover state of the text in the warning color.string#ffc53d
colorWhitePure white color don't changed by themestring#fff
controlHeightLGLG component heightnumber40
controlHeightSMSM component heightnumber24
controlHeightXSXS component heightnumber16
fontSizeHeading1Font size of h1 tag.number38
fontSizeHeading2Font size of h2 tag.number30
fontSizeHeading3Font size of h3 tag.number24
fontSizeHeading4Font size of h4 tag.number20
fontSizeHeading5Font size of h5 tag.number16
fontSizeLGLarge font sizenumber16
fontSizeSMSmall font sizenumber12
fontSizeXLSuper large font sizenumber20
lineHeightLine height of text.number1.5714285714285714
lineHeightHeading1Line height of h1 tag.number1.2105263157894737
lineHeightHeading2Line height of h2 tag.number1.2666666666666666
lineHeightHeading3Line height of h3 tag.number1.3333333333333333
lineHeightHeading4Line height of h4 tag.number1.4
lineHeightHeading5Line height of h5 tag.number1.5
lineHeightLGLine height of large text.number1.5
lineHeightSMLine height of small text.number1.6666666666666667
lineWidthBoldThe default line width of the outline class components, such as Button, Input, Select, etc.number2
motionDurationFastMotion speed, fast speed. Used for small element animation interaction.string0.1s
motionDurationMidMotion speed, medium speed. Used for medium element animation interaction.string0.2s
motionDurationSlowMotion speed, slow speed. Used for large element animation interaction.string0.3s
sizenumber16
sizeLGnumber24
sizeMDnumber20
sizeMSnumber16
sizeSMnumber12
sizeXLnumber32
sizeXSnumber8
sizeXXLnumber48
sizeXXSnumber4

AliasToken

Inherit all SeedToken and MapToken properties

Token NameDescriptionTypeDefault Value
boxShadowControl the box shadow style of an element.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)
boxShadowSecondaryControl the secondary box shadow style of an element.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)
boxShadowTertiaryControl the tertiary box shadow style of an element.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)
colorBgContainerDisabledControl the background color of container in disabled state.stringrgba(0, 0, 0, 0.04)
colorBgTextActiveControl the background color of text in active state.stringrgba(0, 0, 0, 0.15)
colorBgTextHoverControl the background color of text in hover state.stringrgba(0, 0, 0, 0.06)
colorBorderBgControl the color of background border of element.string#ffffff
colorErrorOutlineControl the outline color of input component in error state.stringrgba(255, 38, 5, 0.06)
colorFillAlterControl the alternative background color of element.stringrgba(0, 0, 0, 0.02)
colorFillContentControl the background color of content area.stringrgba(0, 0, 0, 0.06)
colorFillContentHoverControl the style of background color of content area when mouse hovers over it.stringrgba(0, 0, 0, 0.15)
colorHighlightControl the color of page element when highlighted.string#ff4d4f
colorIconWeak action. Such as `allowClear` or Alert close buttonstringrgba(0, 0, 0, 0.45)
colorIconHoverWeak action hover color. Such as `allowClear` or Alert close buttonstringrgba(0, 0, 0, 0.88)
colorLinkControl the color of hyperlink.string#1677ff
colorLinkActiveControl the color of hyperlink when clicked.string#0958d9
colorLinkHoverControl the color of hyperlink when hovering.string#69b1ff
colorSplitUsed as the color of separator, this color is the same as colorBorderSecondary but with transparency.stringrgba(5, 5, 5, 0.06)
colorTextDescriptionControl the font color of text description.stringrgba(0, 0, 0, 0.45)
colorTextDisabledControl the color of text in disabled state.stringrgba(0, 0, 0, 0.25)
colorTextHeadingControl the font color of heading.stringrgba(0, 0, 0, 0.88)
colorTextLabelControl the font color of text label.stringrgba(0, 0, 0, 0.65)
colorTextLightSolidControl the highlight color of text with background color, such as the text in Primary Button components.string#fff
colorTextPlaceholderControl the color of placeholder text.stringrgba(0, 0, 0, 0.25)
colorWarningOutlineControl the outline color of input component in warning state.stringrgba(255, 215, 5, 0.1)
controlInteractiveSizeControl the interactive size of control component.number16
controlItemBgActiveControl the background color of control component item when active.string#e6f4ff
controlItemBgActiveDisabledControl the background color of control component item when active and disabled.stringrgba(0, 0, 0, 0.15)
controlItemBgActiveHoverControl the background color of control component item when hovering and active.string#bae0ff
controlItemBgHoverControl the background color of control component item when hovering.stringrgba(0, 0, 0, 0.04)
controlOutlineControl the outline color of input component.stringrgba(5, 145, 255, 0.1)
controlOutlineWidthControl the outline width of input component.number2
controlPaddingHorizontalControl the horizontal padding of an element.number12
controlPaddingHorizontalSMControl the horizontal padding of an element with a small-medium size.number8
controlTmpOutlineDefault style outline color.stringrgba(0, 0, 0, 0.02)
fontSizeIconControl the font size of operation icon in Select, Cascader, etc. Normally same as fontSizeSM.number12
fontWeightStrongControl the font weight of heading components (such as h1, h2, h3) or selected item.number600
lineWidthFocusControl the width of the line when the component is in focus state.number4
linkDecorationControl the text decoration style of a link.undefined | TextDecoration<string | number>none
linkFocusDecorationControl the text decoration style of a link on focus.undefined | TextDecoration<string | number>none
linkHoverDecorationControl the text decoration style of a link on mouse hover.undefined | TextDecoration<string | number>none
marginControl the margin of an element, with a medium size.number16
marginLGControl the margin of an element, with a large size.number24
marginMDControl the margin of an element, with a medium-large size.number20
marginSMControl the margin of an element, with a medium-small size.number12
marginXLControl the margin of an element, with an extra-large size.number32
marginXSControl the margin of an element, with a small size.number8
marginXXLControl the margin of an element, with the largest size.number48
marginXXSControl the margin of an element, with the smallest size.number4
opacityLoadingControl the opacity of the loading state.number0.65
paddingControl the padding of the element.number16
paddingContentHorizontalControl the horizontal padding of content element.number16
paddingContentHorizontalLGControl the horizontal padding of content element, suitable for large screen devices.number24
paddingContentHorizontalSMControl the horizontal padding of content element, suitable for small screen devices.number16
paddingContentVerticalControl the vertical padding of content element.number12
paddingContentVerticalLGControl the vertical padding of content element, suitable for large screen devices.number16
paddingContentVerticalSMControl the vertical padding of content element, suitable for small screen devices.number8
paddingLGControl the large padding of the element.number24
paddingMDControl the medium padding of the element.number20
paddingSMControl the small padding of the element.number12
paddingXLControl the extra large padding of the element.number32
paddingXSControl the extra small padding of the element.number8
paddingXXSControl the extra extra small padding of the element.number4
screenLGControl the screen width of large screens.number992
screenLGMaxControl the maximum width of large screens.number1199
screenLGMinControl the minimum width of large screens.number992
screenMDControl the screen width of medium screens.number768
screenMDMaxControl the maximum width of medium screens.number991
screenMDMinControl the minimum width of medium screens.number768
screenSMControl the screen width of small screens.number576
screenSMMaxControl the maximum width of small screens.number767
screenSMMinControl the minimum width of small screens.number576
screenXLControl the screen width of extra large screens.number1200
screenXLMaxControl the maximum width of extra large screens.number1599
screenXLMinControl the minimum width of extra large screens.number1200
screenXSControl the screen width of extra small screens.number480
screenXSMaxControl the maximum width of extra small screens.number575
screenXSMinControl the minimum width of extra small screens.number480
screenXXLControl the screen width of extra extra large screens.number1600
screenXXLMinControl the minimum width of extra extra large screens.number1600

StyleProvider

Please ref @ant-design/cssinjs.

How to Debug your Theme

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.

Theme Presets

  • Ant Design 4.x

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 {}.