diff --git a/packages/components/dialog/src/dialog.ts b/packages/components/dialog/src/dialog.ts index ef19088e9b..ec1d4fea53 100644 --- a/packages/components/dialog/src/dialog.ts +++ b/packages/components/dialog/src/dialog.ts @@ -62,7 +62,6 @@ export const dialogProps = { }, top: { type: String, - default: '15vh', }, modelValue: { type: Boolean, @@ -71,7 +70,6 @@ export const dialogProps = { modalClass: String, width: buildProp({ type: [String, Number], - default: '50%', validator: isValidWidthUnit, }), zIndex: { diff --git a/packages/components/dialog/src/use-dialog.ts b/packages/components/dialog/src/use-dialog.ts index 13b0342d17..4ff51250fd 100644 --- a/packages/components/dialog/src/use-dialog.ts +++ b/packages/components/dialog/src/use-dialog.ts @@ -29,9 +29,14 @@ export const useDialog = ( const style = computed(() => { const style: CSSProperties = {} + const varPrefix = `--el-dialog` if (!props.fullscreen) { - style.marginTop = props.top - if (props.width) style.width = normalizeWidth.value + if (props.top) { + style[`${varPrefix}-margin-top`] = props.top + } + if (props.width) { + style[`${varPrefix}-width`] = normalizeWidth.value + } } return style }) diff --git a/packages/theme-chalk/src/common/var.scss b/packages/theme-chalk/src/common/var.scss index 839e50f96c..ace1e8bab8 100644 --- a/packages/theme-chalk/src/common/var.scss +++ b/packages/theme-chalk/src/common/var.scss @@ -643,6 +643,8 @@ $--switch: map.merge( $--dialog: () !default; $--dialog: map.merge( ( + 'width': 50%, + 'margin-top': 15vh, 'background-color': var(--el-color-white), 'box-shadow': 0 1px 3px rgba(0, 0, 0, 0.3), 'title-font-size': var(--el-font-size-large), diff --git a/packages/theme-chalk/src/dialog.scss b/packages/theme-chalk/src/dialog.scss index fb3d470c87..f1dbb20fe5 100644 --- a/packages/theme-chalk/src/dialog.scss +++ b/packages/theme-chalk/src/dialog.scss @@ -10,16 +10,16 @@ @include set-component-css-var('dialog', $--dialog); position: relative; - margin: 0 auto 50px; + margin: var(--el-dialog-margin-top, 15vh) auto 50px; background: var(--el-dialog-background-color); border-radius: var(--el-border-radius-small); box-shadow: var(--el-dialog-box-shadow); box-sizing: border-box; - width: 50%; + width: var(--el-dialog-width, 50%); @include when(fullscreen) { - width: 100%; - margin-top: 0; + --el-dialog-width: 100%; + --el-dialog-margin-top: 0; margin-bottom: 0; height: 100%; overflow: auto;