logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
YouMindTRACTIANLobeHubCodeRabbit
6.4.5
  • Components Overview
  • Changelog
    v6.4.5
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • BorderBeam
      6.4.0
    • ConfigProvider
    • Util
Usage
Content Security Policy
Examples
Locale
Direction
Component size
Theme
Custom Wave
Static function
API
ConfigProvider.config()
ConfigProvider.useConfig()
Component Config
WaveConfig
FAQ
How to contribute a new language?
Date-related components locale is not working?
Modal throw error when setting getPopupContainer?
Why can't ConfigProvider props (like prefixCls and theme) affect ReactNode inside message.info, notification.open, Modal.confirm?
Locale is not working with Vite in production mode?
prefixCls priority(The former is covered by the latter)

ConfigProvider

Provide a uniform configuration support for components.
Importimport { ConfigProvider } from 'antd';
GitHub
components/config-providerIssueOpen issues
Docs
Edit this pageLLMs.md
BorderBeamUtil

Resources

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

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
For Agents
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
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

Usage

This component provides a configuration to all React components underneath itself via the context API. In the render tree all components will have access to the provided config.

tsx
import React from 'react';
import { ConfigProvider } from 'antd';
// ...
const Demo: React.FC = () => (
<ConfigProvider direction="rtl">
<App />
</ConfigProvider>
);
export default Demo;

Content Security Policy

Some components use dynamic style to support wave effect. You can config csp prop if Content Security Policy (CSP) is enabled:

tsx
<ConfigProvider csp={{ nonce: 'YourNonceCode' }}>
<Button>My Button</Button>
</ConfigProvider>

Examples

API

PropertyDescriptionTypeDefaultVersion
componentDisabledConfig antd component disabledboolean-4.21.0
componentSizeConfig antd component sizesmall | medium | large-
cspSet Content Security Policy config{ nonce: string }-
directionSet direction of layout. See demoltr | rtlltr
getPopupContainerTo set the container of the popup element. The default is to create a div element in body(trigger?: HTMLElement) => HTMLElement | ShadowRoot() => document.body
getTargetContainerConfig Affix, Anchor scroll target container() => HTMLElement | Window | ShadowRoot() => window4.2.0
iconPrefixClsSet icon prefix classNamestringanticon4.11.0
localeLanguage package setting, you can find the packages in antd/localeobject-
popupMatchSelectWidthDetermine whether the dropdown menu and the select input are the same width. Default set min-width same as input. Will ignore when value less than select width. false will disable virtual scrollboolean | number-5.5.0
popupOverflowSelect like component popup logic. Can set to show in viewport or follow window scroll'viewport' | 'scroll'
'viewport'5.5.0
prefixClsSet prefix classNamestringant
renderEmptySet empty content of components. Ref Emptyfunction(componentName: string): ReactNode-
themeSet theme, ref Customize ThemeTheme-5.0.0
variantSet variant of data entry componentsoutlined | filled | borderless-5.19.0
virtualDisable virtual scroll when set to falseboolean-4.3.0
warningConfig warning level, when strict is false, it will aggregate deprecated information into a single message{ strict: boolean }-5.10.0
autoInsertSpaceInButtonButton auto spacing config, please use button={{ autoInsertSpace: boolean }} insteadboolean--
dropdownMatchSelectWidthDetermine whether the dropdown menu and the select input are the same width, please use popupMatchSelectWidth insteadboolean--

ConfigProvider.config()

Setting Modal, Message, Notification static config. Does not work on hooks.

tsx
ConfigProvider.config({
// 5.13.0+
holderRender: (children) => (
<ConfigProvider
prefixCls="ant"
iconPrefixCls="anticon"
theme={{ token: { colorPrimary: 'red' } }}
>
{children}
</ConfigProvider>
),
});

ConfigProvider.useConfig() 5.3.0+

Get the value of the parent Provider, Such as DisabledContextProvider, SizeContextProvider.

jsx
const {
componentDisabled, // 5.3.0+
componentSize, // 5.3.0+
} = ConfigProvider.useConfig();
PropertyDescriptionTypeDefaultVersion
componentDisabledantd component disabled stateboolean-5.3.0
componentSizeantd component size statesmall | medium | large-5.3.0

Component Config

The following config keys set common props for corresponding components or global effects. See the related APIs for details:

  • affix: Affix (supported since 6.0.0)
  • alert: Alert (supported since 5.7.0)
  • anchor: Anchor (supported since 6.0.0)
  • app: App (supported since 6.3.0)
  • avatar: Avatar (supported since 5.7.0)
  • badge: Badge (supported since 5.7.0)
  • borderBeam: BorderBeam (supported since 6.4.0)
  • breadcrumb: Breadcrumb (supported since 5.7.0)
  • button: Button (supported since 5.6.0)
  • card: Card (supported since 5.14.0)
  • cardMeta: Card.Meta (supported since 6.0.0)
  • calendar: Calendar (supported since 6.0.0)
  • carousel: Carousel (supported since 5.7.0)
  • cascader: Cascader (supported since 5.13.0)
  • checkbox: Checkbox (supported since 6.0.0)
  • collapse: Collapse (supported since 5.15.0)
  • colorPicker: ColorPicker (supported since 6.3.0)
  • datePicker: DatePicker (supported since 5.7.0)
  • rangePicker: RangePicker (supported since 5.11.0)
  • descriptions: Descriptions (supported since 5.23.0)
  • divider: Divider (supported since 5.10.0)
  • drawer: Drawer (supported since 5.10.0)
  • dropdown: Dropdown (supported since 5.11.0)
  • empty: Empty (supported since 5.23.0)
  • flex: Flex (supported since 5.10.0)
  • floatButton: FloatButton (supported since 6.0.0)
  • floatButtonGroup: FloatButton.Group (supported since 5.16.0)
  • form: Form (supported since 4.8.0)
  • image: Image (supported since 5.14.0)
  • input: Input (supported since 4.2.0)
  • inputNumber: InputNumber (supported since 5.19.0)
  • otp: Input.OTP (supported since 6.0.0)
  • inputPassword: Input.Password (supported since 6.4.0)
  • inputSearch: Input.Search (supported since 6.4.0)
  • textArea: Input.TextArea (supported since 5.15.0)
  • layout: Layout (supported since 5.7.0)
  • list: List (supported since 5.7.0)
  • masonry: Masonry (supported since 6.0.0)
  • menu: Menu (supported since 5.15.0)
  • mentions: Mentions (supported since 5.13.0)
  • message: Message (supported since 5.7.0)
  • modal: Modal (supported since 5.10.0)
  • notification: Notification (supported since 5.14.0)
  • pagination: Pagination (supported since 6.0.0)
  • progress: Progress (supported since 5.7.0)
  • radio: Radio (supported since 6.0.0)
  • rate: Rate (supported since 5.7.0)
  • result: Result (supported since 6.0.0)
  • ribbon: Badge.Ribbon (supported since 6.0.0)
  • skeleton: Skeleton (supported since 6.0.0)
  • segmented: Segmented (supported since 6.0.0)
  • select: Select (supported since 5.13.0)
  • slider: Slider (supported since 5.23.0)
  • switch: Switch (supported since 6.0.0)
  • space: Space (supported since 5.6.0)
  • splitter: Splitter (supported since 5.21.0)
  • spin: Spin (supported since 5.20.0)
  • statistic: Statistic (supported since 6.0.0)
  • steps: Steps (supported since 5.10.0)
  • table: Table (supported since 6.2.0)
  • tabs: Tabs (supported since 5.14.0)
  • tag: Tag (supported since 5.14.0)
  • timeline: Timeline (supported since 6.0.0)
  • timePicker: TimePicker (supported since 5.13.0)
  • tour: Tour (supported since 5.14.0)
  • tooltip: Tooltip (supported since 6.1.0)
  • popover: Popover (supported since 5.23.0)
  • popconfirm: Popconfirm (supported since 5.23.0)
  • qrcode: QRCode (supported since 6.0.0)
  • transfer: Transfer (supported since 5.7.0)
  • tree: Tree (supported since 6.0.0)
  • treeSelect: TreeSelect (supported since 5.19.0)
  • typography: Typography (supported since 6.4.0)
  • upload: Upload (supported since 5.27.0)
  • watermark: Watermark (supported since 6.0.0)
  • wave: WaveConfig (supported since 5.8.0)

WaveConfig

PropertyDescriptionTypeDefaultVersion
disabledWhether to disable wave effectbooleanfalse
showEffectCustomized wave effect(node: HTMLElement, info: { className, token, component }) => void-
triggerTypeThe event that triggers wave effectclick | pointerdown | pointerup | mousedown | mouseupclick6.4.0

FAQ

How to contribute a new language?

See <Adding new language>.

Date-related components locale is not working?

See FAQ Date-related-components-locale-is-not-working?

Modal throw error when setting getPopupContainer?

Related issue: https://github.com/ant-design/ant-design/issues/19974

When you config getPopupContainer to parentNode globally, Modal will throw error of triggerNode is undefined because it did not have a triggerNode. You can try the fix below.

diff
<ConfigProvider
- getPopupContainer={triggerNode => triggerNode.parentNode}
+ getPopupContainer={node => {
+ if (node) {
+ return node.parentNode;
+ }
+ return document.body;
+ }}
>
<App />
</ConfigProvider>

Why can't ConfigProvider props (like prefixCls and theme) affect ReactNode inside message.info, notification.open, Modal.confirm?

antd will dynamic create React instance by ReactDOM.render when call message methods. Whose context is different with origin code located context. We recommend useMessage, useNotification and useModal which , the methods came from message/notification/Modal has been deprecated in 5.x.

Locale is not working with Vite in production mode?

Related issue: #39045

In production mode of Vite, default exports from cjs file should be used like this: enUS.default. So you can directly import locale from es/ directory like import enUS from 'antd/es/locale/en_US' to make dev and production have the same behavior.

prefixCls priority(The former is covered by the latter)

  1. ConfigProvider.config({ prefixCls: 'prefix-1' })
  2. ConfigProvider.config({ holderRender: (children) => <ConfigProvider prefixCls="prefix-2">{children}</ConfigProvider> })
  3. message.config({ prefixCls: 'prefix-3' })
Locale

Components which need localization support are listed here, you can toggle the language in the demo.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Direction

Components which support rtl direction are listed here, you can toggle the direction in the demo.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Component size

Config component default size.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Theme

Modify theme by theme prop.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom Wave

Wave effect brings dynamic. Use component to determine which component use it. You can also use HappyProvider from @ant-design/happy-work-theme to implement dynamic wave effect.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Static function

Use holderRender to set the Provider for the static methods message,modal,notification.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Change locale of components:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 10 / page
Click to confirm
0 item
No data
No data
0 item
No data
No data
2026
Jun
SuMoTuWeThFrSa
31
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
01
02
03
04
05
06
07
08
09
10
11
Name
Age
No data
No data

QR code expired

image.pngimage.png
Uploading...
image.png
image.png
Tour
Change direction of components:
Cascader example
یک مورد انتخاب کنید
    With search:  
Select an item
Switch example
      
Radio Group example
Button example
Tree example
parent 1
parent 1-0
leaf
leaf
parent 1-1
sss
Input (Input Group) example
Option1
Http://
.com
Select example
مورچه
مورچه
مورچه
Select a person
TreeSelect example
Please select
Modal example
Steps example
Finished
This is a description.
In Progress
This is a description.
Waiting
This is a description.
1
Step 1
This is a description.
2
Step 2
This is a description.
3
Step 3
This is a description.
Rate example
* Note: Half star not implemented in RTL direction, it will be supported after rc-rate implement rtl support.
Badge example
5
Pagination example
  • 1
  • 2
  • 3
  • 4
  • 5
  • 50
  • 10 / page
Grid System example

* Note: Every calculation in RTL grid system is from right side (offset, push, etc.)

col-8
col-8
col-6 col-offset-6
col-6 col-offset-6
col-12 col-offset-6
col-18 col-push-6
col-6 col-pull-18
Tab 1
Tab 2
Tab 3
Content of Tab Pane 1
demo
Card
NameAge
John Brown32
Jim Green42
Joe Black32
  • 1