Files
element-plus/docs/en-US/component/config-provider.md
知晓同丶 98041055b0 feat(components): [message] add placement option & method (#21747)
* feat(components): [message] add `placement` option & method

* fix: resolve test hanging issue caused by reactive circular dependency

* test: add test

* feat: add placement `top-left/top-right/bottom-left/bottom-right`

* refactor: split large normalizeOptions function

* docs: adjust description text

* chore: remove unused height expose

* refactor: simpify code

* style: opt-in center style & simplified animations

* style: replace :not(.center) with :is(.left,.right) for more explicit

* feat: add `placement` to `config-provider`

* fix: fix test warning when placement is undefined

* refactor: remove useless style & simpify types

* fix: avoid circular dependency

* chore: types related

* Update docs/examples/config-provider/message.vue

Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>

* Update packages/components/config-provider/__tests__/config-provider.test.tsx

Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>

* chore: make typecheck happy & format

* style: add top/bottom transition

* chore: format

---------

Co-authored-by: zhixiaotong <947803089@qq.com>
Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>
Co-authored-by: Dsaquel <291874700n@gmail.com>
2025-08-19 15:16:49 +00:00

15 KiB

title, lang
title lang
Config Provider en-US

Config Provider

Config Provider is used for providing global configurations, which enables your entire application to access these configurations everywhere.

i18n Configurations

Configure i18n related properties via Config Provider, to get language switching feature.

:::demo Use two attributes to provide i18n related config

config-provider/usage

:::

Button Configurations

:::demo

config-provider/button

:::

:::demo

config-provider/link

:::

Card Configurations ^(2.10.5)

:::demo

config-provider/card

:::

Dialog Configurations ^(2.10.7)

:::demo

config-provider/dialog

:::

Message Configurations

:::demo

config-provider/message

:::

Empty Values Configurations ^(2.7.0)

Supported components list
  • Cascader
  • ColorPicker ^(2.10.3)
  • DatePicker
  • Select
  • SelectV2
  • TimePicker
  • TimeSelect
  • TreeSelect

Set empty-values to support empty values of components. The fallback value is ['', null, undefined]. If you think the empty string is meaningful, write [undefined, null].

Set value-on-clear to set the return value when cleared. The fallback value is undefined. In the date component is null. If you want to set undefined, use () => undefined.

:::demo

config-provider/empty-values

:::

Experimental features

In this section, you can learn how to use Config Provider to provide experimental features. For now, we haven't added any experimental features, but in the feature roadmap, we will add some experimental features. You can use this config to manage the features you want or not.

API

Config Provider Attributes

Name Description Type Default
locale Locale Object ^[object]{name: string, el: TranslatePair} languages en
size global component size ^[enum]'large' | 'default' | 'small' default
zIndex global Initial zIndex ^[number]
namespace global component className prefix (cooperated with $namespace) ^[string] el
button button related configuration, see the following table ^[object]{autoInsertSpace?: boolean, type?: string, plain?: boolean, round?: boolean} see the following table
link link related configuration, see the following table ^[object]{type?: string, underline?: boolean | string} see the following table
dialog ^(2.10.7) dialog related configuration, see the following table ^[object]{alignCenter?: boolean, draggable?: boolean, overflow?: boolean, transition?: DialogTransition} see the following table
message message related configuration, see the following table ^[object]{max?: number} see the following table
experimental-features features at experimental stage to be added, all features are default to be set to false ^[object]
empty-values ^(2.7.0) global empty values of components ^[array]
value-on-clear ^(2.7.0) global clear return value ^[string] / ^[number] / ^[boolean] / ^[Function]

Button Attribute

Attribute Description Type Default
type ^(2.9.11) button type, when setting color, the latter prevails ^[enum]'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' (deprecated)
autoInsertSpace automatically insert a space between two chinese characters(this will only take effect when the text length is 2 and all characters are in Chinese.) ^[boolean] false
plain ^(2.9.11) determine whether it's a plain button ^[boolean] false
text ^(2.11.0) determine whether it's a text button ^[boolean] false
round ^(2.9.11) determine whether it's a round button ^[boolean] false
Attribute Description Type Default
type ^(2.9.11) type ^[enum]'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default' default
underline ^(2.9.11) when underlines should appear ^[enum]'always' | 'hover' | 'never' | boolean hover

Card Attribute

Attribute Description Type Default
shadow ^(2.10.5) when to show card shadows ^[enum]always | never | hover

Dialog Attribute

Attribute Description Type Default
align-center ^(2.10.7) whether to align the dialog both horizontally and vertically ^[boolean] false
draggable ^(2.10.7) enable dragging feature for Dialog ^[boolean] false
overflow ^(2.10.7) draggable Dialog can overflow the viewport long ^[boolean] false
transition ^(2.10.7) custom transition configuration for dialog animation. Can be a string (transition name) or an object with Vue transition props ^[string] / ^[object]TransitionProps

Message Attribute

Attribute Description Type Default
max the maximum number of messages that can be displayed at the same time ^[number]
grouping ^(2.8.2) merge messages with the same content, type of VNode message is not supported ^[boolean]
duration ^(2.8.2) display duration, millisecond. If set to 0, it will not turn off automatically ^[number]
showClose ^(2.8.2) whether to show a close button ^[boolean]
offset ^(2.8.2) set the distance to the top of viewport ^[number]
plain ^(2.9.11) whether message is plain ^[boolean]
placement ^(2.11.0) message placement position ^[enum]'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right'

Config Provider Slots

Name Description Scope
default customize default content config: provided global config (inherited from the top)