JGuang

ConfigProvider

ConfigProvider · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

ConfigProvider

Configure in the outermost layer of the application to set global params.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Set the basic usage of internationalized languages.
  • Pagination: Configure global table pagination parameters. For example, you can set tablePagination.hideOnSinglePage to hide the pagination when the table data is less than or equal to one page.
  • renderEmpty: Use renderEmpty to define the empty elements displayed in the component.
  • Component Config: Set the default configuration of each component globally.
  • RTL: Set the component to a view that reads from right to left.
  • local settings Message config: prefixCls and rtl set by ConfigProvider will be applied to all Message and Notification by default If you want to work only inside ConfigProvider, you need to use it in combination with useMessage or useNotification, and turn off effectGlobalNotice This is supported in 2.40.0
  • local settings Modal config: prefixCls and rtl set through ConfigProvider will act on all Modal function methods by default. If you want local settings not to affect the global configuration, you can turn off effectGlobalModal. This is supported in 2.61.0

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

ConfigProvider

PropertyDescriptionTypeDefaultValueVersion
autoInsertSpaceInButtonWhen there are two Chinese characters in the button, a space is automatically added between two Chinese characters.boolean-2.3.0
effectGlobalModalWhether to set all Modal configuration globally.booleantrue2.61.0
effectGlobalNoticeWhether to update the configuration of all Message and Notification with one click. Set to false if using the hook locale of useMessagebooleantrue2.40.0
rtlView starts from the right and ends on the left.boolean-2.36.0
prefixClsGlobal ClassName prefixstringarco-
sizeConfigure the default size of the component, which will only take effect for components that support the size property.'mini' | 'small' | 'default' | 'large'default-
loadingElementGlobal loading icon.ReactNode--
componentConfigDefault parameters for global configuration of all componentsComponentConfig-2.23.0
focusLockglobal focusLock, affects component Modal Drawer.{modal?: boolean | { autoFocus?: boolean };drawer?: boolean | { autoFocus?: boolean };}{ modal: { autoFocus: true }, drawer: { autoFocus: true }}2.13.0
localeLanguage package settingLocale--
tablePaginationTable Global pagination configuration.PaginationProps-2.6.0
themeTheme ConfigurationThemeConfig--
getPopupContainerThe parent node of the global popup.(node: HTMLElement) => Element() => document.body-
renderEmptyEmpty component in component.(componentName?: string) => ReactNode-2.10.0

ComponentConfig

export type ComponentConfig = {
  Affix?: AffixProps;
  Alert?: AlertProps;
  AutoComplete?: AutoCompleteProps;
  Avatar?: AvatarProps;
  "Avatar.Group"?: AvatarGroupProps;
  Anchor?: AnchorProps;
  "Anchor.Link"?: AnchorLinkProps;
  BackTop?: BackTopProps;
  Badge?: BadgeProps;
  Breadcrumb?: BreadcrumbProps;
  Button?: ButtonProps;
  Calendar?: CalendarProps;
  Card?: CardProps;
  Carousel?: CarouselProps;
  Cascader?: CascaderProps;
  Checkbox?: CheckboxProps;
  Collapse?: CollapseProps;
  Comment?: CommentProps;
  ColorPicker?: ColorPickerProps;
  DatePicker?: Omit<
    DatePickerCommonProps,
    | "placeholder"
    | "onChange"
    | "onSelect"
    | "onOk"
    | "defaultPickerValue"
    | "pickerValue"
    | "onPickerValueChange"
    | "inputProps"
  >;
  Descriptions?: DescriptionsProps;
  Divider?: DividerProps;
  Drawer?: DrawerProps;
  Dropdown?: DropdownProps;
  "Dropdown.Button"?: DropdownButtonProps;
  Empty?: EmptyProps;
  "Typography.Ellipsis"?: TypographyEllipsisProps;
  Form?: FormProps;
  "Grid.Row"?: RowProps;
  "Grid.Col"?: ColProps;
  Grid?: GridProps;
  "Grid.GridItem"?: GridItemProps;
  Image?: ImageProps;
  Input?: InputProps;
  InputNumber?: InputNumberProps;
  VerificationCode?: VerificationCodeProps;
  Watermark?: WatermarkProps;
  InputTag?: InputTagProps;
  Layout?: LayoutProps;
  Link?: LinkProps;
  List?: ListProps;
  "List.Item"?: ListItemProps;
  Mentions?: MentionsProps;
  Menu?: MenuProps;
  Modal?: ModalProps;
  PageHeader?: PageHeaderProps;
  Pagination?: PaginationProps;
  Popconfirm?: PopconfirmProps;
  Popover?: PopoverProps;
  Progress?: ProgressProps;
  Radio?: RadioProps;
  "Radio.Group"?: RadioGroupProps;
  Rate?: RateProps;
  ResizeBox?: ResizeBoxProps;
  Result?: ResultProps;
  Select?: SelectProps;
  Skeleton?: SkeletonProps;
  Slider?: SliderProps;
  Space?: SpaceProps;
  Spin?: SpinProps;
  Statistic?: StatisticProps;
  Steps?: StepsProps;
  Switch?: SwitchProps;
  Table?: TableProps;
  Tabs?: TabsProps;
  TreeProps?: TreeProps;
  TriggerProps?: TriggerProps;
  Tag?: TagProps;
  Timeline?: TimelineProps;
  "Timeline.Item"?: TimelineItemProps;
  TimePicker?: TimePickerCommonProps;
  Tooltip?: TooltipProps;
  Transfer?: TransferProps;
  Tree?: TreeProps;
  TreeSelect?: TreeSelectProps;
  Trigger?: TriggerProps;
  Upload?: UploadProps;
};

Locale

export interface Locale {
  locale: string;
  dayjsLocale?: string;
  Calendar: CalendarType;
  DatePicker: {
    Calendar: CalendarType;
    [key: string]: any;
  };
  Drawer: Record<string, any>;
  Empty: Record<string, any>;
  Modal: Record<string, any>;
  Pagination: Record<string, any>;
  Popconfirm: Record<string, any>;
  Table: Record<string, any>;
  TimePicker: Record<string, any>;
  Upload: Record<string, any>;
  Progress: Record<string, any>;
  Typography: Record<string, any>;
  Transfer: Record<string, any>;
  ImagePreview: Record<string, any>;
  Form?: Record<string, any>;
  ColorPicker: Record<string, any>;
}

CalendarType

type CalendarType = {
  today: string;
  view: Record<string, any>;
  month: {
    short: Record<string, any>;
    long: Record<string, any>;
  };
  week: {
    short: Record<string, any>;
    long: Record<string, any>;
  };
  formatYear?: string;
  formatMonth?: string;
  monthBeforeYear?: boolean;
};

ThemeConfig

export type ThemeConfig = Record<string, any>;