Show · Modal

Modal

Modals are used to wait for the user to interact, inform the user of important information, or display more information without losing context.

Demos

How to import

<script setup lang="ts">
    import { Modal } from '@fibrous/semi-ui-vue';
</script>

Basic Usage

Use v-model:visible to control visibility. v-model:visible updates only on the cancel paths: the cancel button, the close button, the mask and Esc. When onCancel returns a Promise, it updates after the Promise fulfills, and a rejection keeps the modal open. Clicking the ok button only triggers @ok; the caller sets visible to false. While the @cancel callback runs, the parent's visible is still true.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const handleOk = () => {
        visible.value = false;
        console.log('Ok button clicked');
    };
    const handleCancel = () => {
        console.log('Cancel button clicked');
    };
    const handleAfterClose = () => {
        console.log('After Close callback executed');
    };
</script>

<template>
    <Button @click="visible = true">打开弹窗</Button>
    <Modal v-model:visible="visible" closeOnEsc title="基本对话框" @afterClose="handleAfterClose" @cancel="handleCancel" @ok="handleOk">
        This is the content of a basic modal.
        <br />
        More content...
    </Modal>
</template>

Bottom Button Fill up

Set footerFill to true to make the bottom buttons of the Modal footer fill up the arrangement.

Mask Closable

You can set maskClosable={false} to prevent modal from closing when clicking on the mask.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const close = () => {
        visible.value = false;
    };
</script>

<template>
    <Button @click="visible = true">点击遮罩层不可关闭</Button>
    <Modal v-model:visible="visible" :maskClosable="false" title="对话框标题" @ok="close">
        <p>This is a modal that cannot be closed by clicking on the mask.</p>
        <p>More content...</p>
    </Modal>
</template>

Custom Button Text

You can set button text using okText and cancelText.

A modal created with static methods is rendered outside the component tree and cannot read the locale from ConfigProvider or LocaleProvider. Set the texts with these two properties, or use Modal.useModal.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const close = () => {
        visible.value = false;
    };
</script>

<template>
    <Button @click="visible = true">自定义按钮文字</Button>
    <Modal v-model:visible="visible" cancelText="No, thanks." okText="Sounds great!" title="自定义按钮文字" @ok="close">
        <p>This is a modal with customized button texts.</p>
        <p>More content...</p>
    </Modal>
</template>

Custom Button Properties

You can set button properties using okButtonProps and cancelButtonProps. Their onClick runs before the built-in handling and does not replace it.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const close = () => {
        visible.value = false;
    };
</script>

<template>
    <Button @click="visible = true">自定义按钮属性</Button>
    <Modal v-model:visible="visible" :cancelButtonProps="{ size: 'small', disabled: true }" :okButtonProps="{ size: 'small', type: 'warning' }" title="自定义按钮属性" @ok="close">
        <p>This is a modal with customized button props.</p>
        <p>More content...</p>
    </Modal>
</template>

For more customized modal, you could use the #header and #footer slots. An empty #header slot (<template #header />) removes the header area, and an empty #footer slot removes the footer area including buttons.

Custom Style

You can use style to customize styling or position e.g. style.top = '30vh', or use centered to center modal. Also, you could use maskStyle to customize mask style or bodyStyle for content style.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const close = () => {
        visible.value = false;
    };
</script>

<template>
    <Button @click="visible = true">自定义对话框样式</Button>
    <Modal v-model:visible="visible" :bodyStyle="{ overflow: 'auto', height: '200px' }" centered title="自定义样式" @ok="close">
        <p :style="{ lineHeight: 1.8 }">Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。</p>
        <p :style="{ lineHeight: 1.8 }">区别于其他的设计系统而言,Semi Design 以用户中心、内容优先、设计人性化为设计理念,具有以下优势:</p>
        <ul>
            <li>
                <p>Semi Design 以内容优先进行设计。</p>
            </li>
            <li>
                <p>更容易地自定义主题。</p>
            </li>
            <li>
                <p>适用国际化场景。</p>
            </li>
            <li>
                <p>效率场景加入人性化关怀</p>
            </li>
        </ul>
    </Modal>
</template>

Custom Modal

By using the #header, #footer slots, etc, you could create any modal to your needs.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { IconSemiLogo, IconVigoLogo } from '@fibrous/semi-icons-vue';
    import { Button, List, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const data = [
        {
            icon: IconSemiLogo,
            title: 'Boost new feature adoption with Integration',
            content: 'Sample data is prepared for you to demonstrate how Integration may be useful for your team',
        },
        {
            icon: IconVigoLogo,
            title: 'Introducing Dark Mode',
            content: 'Sample data is prepared for you to demonstrate how Integration may be useful for your team',
        },
        {
            icon: IconSemiLogo,
            title: 'New List Component',
            content: 'Sample data is prepared for you to demonstrate how Integration may be useful for your team',
        },
    ];
    const btnStyle = {
        width: '240px',
        margin: '4px 50px',
    };
</script>

<template>
    <Button @click="visible = true">自定义对话框</Button>
    <Modal v-model:visible="visible">
        <template #header />
        <h3 :style="{ textAlign: 'center', fontSize: '24px', margin: '40px' }">Semi Design New Features</h3>
        <List :dataSource="data" :split="false">
            <template #item="{ item }">
                <List.Item>
                    <template #header>
                        <component :is="item.icon" :style="{ fontSize: '48px' }" />
                    </template>
                    <template #main>
                        <div>
                            <h6 :style="{ margin: 0, fontSize: '16px' }">{{ item.title }}</h6>
                            <p :style="{ marginTop: '4px', color: 'var(--semi-color-text-1)' }">{{ item.content }}</p>
                        </div>
                    </template>
                </List.Item>
            </template>
        </List>
        <template #footer>
            <div :style="{ textAlign: 'center' }">
                <Button :style="btnStyle" theme="solid" type="primary" @click="visible = false">Continue</Button>
                <Button :style="btnStyle" theme="borderless" type="primary" @click="visible = false"> Learn more features </Button>
            </div>
        </template>
    </Modal>
</template>

Full Screen Modal

Set fullScreen to use full screen Modal

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
    const close = () => {
        visible.value = false;
    };
</script>

<template>
    <Button @click="visible = true">打开全屏弹窗</Button>
    <Modal v-model:visible="visible" fullScreen title="全屏对话框标题" @ok="close">
        <p>This is a full screen modal</p>
        <p>More content...</p>
    </Modal>
</template>

Confirm Modal

You could use static methods to create a confirm Modal. Use icon to customize icon. The title, content, icon, closeIcon, header and footer options take a ModalNode: a string, a VNode, or a function returning VNodeChild (rendered as a functional component, so it can inject).











Code
<script setup lang="ts">
    import { h } from 'vue';
    import { IconSend } from '@fibrous/semi-icons-vue';
    import { Button, Modal } from '@fibrous/semi-ui-vue';

    const success = () => Modal.success({ title: 'This is a success message', content: 'bla bla bla...' });
    const info = () => Modal.info({ title: 'Here is some info', content: 'bla bla bla...' });
    const error = () => Modal.error({ title: 'Unfortunately, there is an error', content: 'bla bla bla...' });
    const warning = () => Modal.warning({ title: 'Warning: be cautious ahead', content: 'bla bla bla...' });
    const confirm = () => Modal.confirm({ title: 'Are you sure ?', content: 'bla bla bla...' });
    const custom = () =>
        Modal.info({
            title: 'This is a custom modal',
            content: 'bla bla bla...',
            icon: h(IconSend),
            cancelButtonProps: { theme: 'borderless' },
            okButtonProps: { theme: 'solid' },
        });
</script>

<template>
    <div>
        <Button @click="info">Info</Button>
        <br />
        <br />
        <Button @click="success">Success</Button>
        <br />
        <br />
        <Button type="danger" @click="error">Error</Button>
        <br />
        <br />
        <Button type="warning" @click="warning">Warning</Button>
        <br />
        <br />
        <Button type="primary" @click="confirm">Confirm</Button>
        <br />
        <br />
        <Button @click="custom">Custom</Button>
    </div>
</template>

useModal Hooks

Modal.useModal() returns [modal, Holder]. Place <Holder /> where the context should be read, and the modals created with modal.confirm and the other methods can access the provides, ConfigProvider and locale at that position.

Code
<script setup lang="ts">
    import en_GB from '@fibrous/semi-foundation/locale/source/en_GB';
    import { Button, ConfigProvider, Modal } from '@fibrous/semi-ui-vue';

    const [modal, Holder] = Modal.useModal();
    const config = { title: 'This is a success message', content: 'Context consumer' };
</script>

<template>
    <ConfigProvider :locale="en_GB">
        <div>
            <Button @click="modal.confirm(config)">Confirm Modal</Button>
        </div>
        <Holder />
    </ConfigProvider>
</template>

Draggable Modal

The modal content is rendered customly through the #modal="{ modal }" slot. modal is the VNode of the role="dialog" element; place it with <component :is="modal" />. The draggable Modal is implemented through the DragMove component.

Code
<script setup lang="ts">
    import { ref } from 'vue';
    import { Button, DragMove, Modal } from '@fibrous/semi-ui-vue';

    const visible = ref(false);
</script>

<template>
    <div>
        <Button @click="visible = true">Open Modal</Button>
        <Modal v-model:visible="visible" centered title="可拖拽Modal">
            <template #modal="{ modal }">
                <DragMove positionStrategy="relative">
                    <component :is="modal" />
                </DragMove>
            </template>
            <p>This is the content of a basic sidesheet.</p>
            <p>Here is more content...</p>
        </Modal>
    </div>
</template>

API Reference

Props

PropertyDescriptionTypeDefault
bodyStyleStyle of the dialog body.StyleValuesemiGlobalDefault("Modal", "bodyStyle")
cancelButtonPropsProps of the cancel button. autoFocus focuses it on open; class and style land on the button; onClick runs before the built-in cancel handling, which still runs.ModalButtonPropssemiGlobalDefault("Modal", "cancelButtonProps")
cancelLoadingWhether the cancel button is loading. When omitted it follows the Promise returned by onCancel; pass false to turn that off.booleansemiGlobalDefault("Modal", "cancelLoading")
cancelTextCancel button text. Defaults to the locale entry Modal.cancel.stringsemiGlobalDefault("Modal", "cancelText")
centeredWhether the dialog is vertically centered.booleansemiDefault("Modal", "centered", false)
closableWhether the close button in the corner is shown.booleansemiDefault("Modal", "closable", true)
closeOnEscWhether Esc cancels the dialog.booleansemiDefault("Modal", "closeOnEsc", true)
confirmLoadingWhether the ok button is loading. When omitted it follows the Promise returned by onOk; pass false to turn that off.booleansemiGlobalDefault("Modal", "confirmLoading")
footerFillWhether the two buttons of the default footer fill the row.booleansemiGlobalDefault("Modal", "footerFill")
fullScreenWhether the dialog fills the screen. width and height are ignored.booleansemiDefault("Modal", "fullScreen", false)
getPopupContainerParent element the dialog is rendered into. A custom container needs position: relative; this changes where the dialog sits in the DOM, not where it is shown.Type(() => HTMLElement)undefined
hasCancelWhether the default footer shows the cancel button.booleansemiDefault("Modal", "hasCancel", true)
heightHeight of the dialog. A number is in pixels; a string is any valid CSS length.string | numbersemiGlobalDefault("Modal", "height")
keepDOMWhether the dialog content stays mounted while closed.booleansemiDefault("Modal", "keepDOM", false)
lazyRenderUsed with keepDOM. When true, the dialog is not rendered until it is first shown.booleansemiDefault("Modal", "lazyRender", true)
maskWhether the mask is shown.booleansemiDefault("Modal", "mask", true)
maskClosableWhether a click on the mask cancels the dialog.booleansemiDefault("Modal", "maskClosable", true)
maskFixedWhether a mask confined to a custom container still covers the viewport with fixed positioning and is treated as modal (aria-modal, inert page, Tab lock, body scroll lock).booleansemiDefault("Modal", "maskFixed", false)
maskStyleStyle of the mask.StyleValuesemiGlobalDefault("Modal", "maskStyle")
modalContentClassClass name of the dialog content element.stringsemiGlobalDefault("Modal", "modalContentClass")
motionWhether the enter and leave animations run.booleansemiDefault("Modal", "motion", true)
okButtonPropsProps of the ok button. autoFocus focuses it on open; class and style land on the button; onClick runs before the built-in ok handling, which still runs.ModalButtonPropssemiGlobalDefault("Modal", "okButtonProps")
okTextOk button text. Defaults to the locale entry Modal.confirm.stringsemiGlobalDefault("Modal", "okText")
okTypeType of the ok button.OKTypesemiDefault("Modal", "okType", "primary")
preventScrollWhether the focus calls made by the component avoid scrolling the focused element into view. Focus calls made by the caller are not affected.booleansemiGlobalDefault("Modal", "preventScroll")
sizeWidth preset of the dialog: small is 448px, medium 684px, large 920px, full-width 100vw - 64px.SizesemiDefault("Modal", "size", "small")
titlePlain-text title, which also names the dialog. The #title slot wins when both are given. It is a declared prop, so it never lands on an element as the native title attribute.stringsemiGlobalDefault("Modal", "title")
visibleWhether the dialog is visible, used with v-model:visible.booleansemiDefault("Modal", "visible", false)
widthWidth of the dialog. A number is in pixels; a string is any valid CSS length. When omitted, size decides.string | numbersemiGlobalDefault("Modal", "width")
zIndexz-index of the outer layer.numbersemiDefault("Modal", "zIndex", 1000)
onCancelCalled by the cancel button, the close button, the mask and Esc; the argument is a native KeyboardEvent for Esc. A returned Promise keeps the cancel button loading; v-model:visible updates once it fulfills, and a rejection keeps the dialog open. The parent's visible is still true while the callback runs. It remains a function prop so its result can be read, bound with @cancel as usual.Type((event: MouseEvent | KeyboardEvent) => void | Promise<unknown>)undefined
onOkCalled when the ok button is clicked. A returned Promise keeps the ok button loading until it settles. The component never closes itself on ok; the caller sets visible to false. It remains a function prop so its result can be read, bound with @ok as usual.Type((event: MouseEvent) => void | Promise<unknown>)undefined

Events

EventDescriptionCallback parameters
update:visibleEmitted with false once a cancel path (cancel button, close button, mask, Esc) completes, for v-model:visible to write back. Ok only calls onOk and never emits this.[visible: boolean]
afterCloseEmitted after the dialog has fully closed. It is also emitted once when the dialog is unmounted while shown.[]

Slots

SlotDescriptionScope parameters
defaultBody of the dialog.any
titleTitle. It wins over the title prop and names the dialog.any
headerReplaces the whole default header (icon, title and close button). An empty slot hides the header area.any
footerReplaces the default footer buttons. An empty slot hides the footer area.any
iconIcon before the title.any
closeIconIcon inside the close button. An empty slot falls back to the default icon.any
modalCustom rendering of the dialog itself. The scope parameter modal is the VNode of the role=dialog element; place it with <component :is="modal" />.Type{ modal: VNode<RendererNode, RendererElement, { [key: string]: any; }>; }

Exposes

NameDescriptionType
rootThe outermost element inside the portal, or null while nothing is rendered.HTMLDivElement | null

role and every aria-* attribute land on the role="dialog" element, style lands on the .semi-modal dialog box, and class and other native attributes land on the outermost element inside the portal. The Modal component has no content prop; put the dialog content in the default slot. The content option is only for the static methods below.

Static Method

  • Modal.info
  • Modal.success
  • Modal.error
  • Modal.warning
  • Modal.confirm

ModalNode is string | VNode | (() => VNodeChild). A function is rendered as a functional component, so it can inject.

PropertiesInstructionstypeDefault
afterCloseCallback function when modal closed completely() => void-
bodyStyleContent styleStyleValue-
cancelButtonPropsProperties for cancel button; its onClick runs before the built-in handling and does not replace itModalButtonProps-
cancelTextText for cancel buttonstring-
centeredToggle whether to center modalbooleanfalse
classClass namestring | object | array-
closableToggle whether to show close buttonbooleantrue
closeIconIcon for close buttonModalNode<IconClose />
confirmLoadingToggle loading state of confirm button; when unset it follows the pending state of the Promise returned by onOk, pass false to turn that offboolean-
contentContentModalNode-
directionText direction. The static methods render outside any ConfigProvider, so pass it yourself; the useModal methods follow the ConfigProvider where Holder is placed by default'ltr' | 'rtl'-
footerFooter; null removes the footer areaModalNode | null-
footerFillIs the bottom button fullbooleanfalse
headerHeader; null removes the header areaModalNode | null-
heightHeightstring | number-
iconCustomized iconModalNode-
maskToggle whether to show maskbooleantrue
maskClosableToggle whether to allow closing when clicking maskbooleantrue
maskStyleMask styleStyleValue-
modalContentClassThe class name that can be used to set the style of the dialog contentstring-
modalRenderCustom rendering Modal; the argument is the VNode of the role="dialog" element(modal: VNode) => VNodeChild-
motionAnimation switch; changing it with update takes effect toobooleantrue
okButtonPropsProperties for confirm button; its onClick runs before the built-in handling and does not replace itModalButtonProps-
okTextText for confirm buttonstring-
okTypeType for confirm buttonOKTypeprimary
styleInline styleStyleValue-
titleTitleModalNode-
widthWidth; when unset, size decides (448 for small)string | number-
zIndexZ-index value for masknumber1000
onCancelCallback function when clicking cancel button; a returned Promise closes the modal after it fulfills, and a rejection keeps it open; closing with Esc passes the native KeyboardEvent(event: MouseEvent | KeyboardEvent) => void | Promise<unknown>-
onOkCallback function when clicking confirm button; a returned Promise closes the modal after it fulfills, and a rejection keeps it open(event: MouseEvent) => void | Promise<unknown>-

aria-* and data-* options land on the dialog. Creating modal with the above methods will return a reference to the instance. You could use it to update or close the modal. update takes the same options as the methods above (ModalConfirmProps) and merges them into the current config; it does not take type.

const modal = Modal.info({ title: 'Title' });

modal.update({
    title: 'Updated Title',
    content: 'Updated Content',
});

modal.destroy();
  • Modal.destroyAll

You could use Modal.destroyAll() to destroy Modal that created by methods above e.g. .info()

  • Modal.useModal
    When you need to read context, call const [modal, Holder] = Modal.useModal() and place <Holder /> at the corresponding position. Modals created through modal can access everything at the position of Holder (provide, ConfigProvider, locale). The modal object shares the same methods with Modal.method.
  • app.use(Modal)
    Optional. Imperative dialogs then render with that app's context, so they can read values from app.provide() and globally registered components. The static methods of Toast, Notification and Modal share this record, so installing any one of them applies to all three; when several apps install, the last one wins.

Accessibility

ARIA

WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/

  • The Modal component has role dialog, following the APG Dialog (Modal) pattern
  • Confirm dialogs (Modal.confirm, info, success, warning, error, and the same-named useModal methods) have role alertdialog, and aria-describedby points to the message, following the APG Alert Dialog pattern
  • aria-modal is set to true when the dialog is modal. A dialog is modal when it has a mask (mask) and is mounted in the body (judged by the actual container, so the getPopupContainer of ConfigProvider counts) or has maskFixed. With mask={false}, or a mask confined to a custom container, the page behind stays usable and aria-modal is omitted
  • aria-labelledby corresponds to the dialog title; it is not generated when aria-label or a custom header is given
  • The Modal component does not set aria-describedby by default: when the body holds a form, a list or several paragraphs, reading it out whole gets in the way. Pass it yourself when needed
  • role and every aria-* attribute passed by the caller land on the element that carries the role
  • The close button's aria-label comes from the current locale ('Close' in English, '关闭' in Simplified Chinese)

Keyboard and focus

  • Modal automatically gets the focus when it is popped up. An element with autoFocus (autofocus in Vue) inside the dialog gets the focus first; otherwise the cancel button does by default, which can be controlled by passing autoFocus in cancelButtonProps or okButtonProps. With keepDOM, opening it again gives the same result; with keepDOM and lazyRender={false} that starts hidden, an autoFocus element cannot take focus under display: none, so later openings land on the default button.
  • When a modal dialog is closed, the focus automatically returns to the element before it was opened. Keyboard users can use the Tab key and Shift + Tab to move the focus in a loop within the Modal, including the Modal's own close button and OK cancel button. At this time, the page behind the Modal cannot be interacted with or tab-focused.
  • A non-modal dialog (mask={false}, or a mask confined to a custom container without maskFixed) also takes focus when opened, but does not lock Tab and the rest of the page stays usable. When closed, focus is returned only if it is still inside the dialog or has fallen to the body; focus the user has moved elsewhere on the page stays. A Modal in the body with mask={false} does not lock body scrolling.
  • Modify the default value of closeOnEsc to true, allowing users to directly close Modal through the keyboard for a better experience

Content Guidelines

  • Imperative Modal and Default Modal The title of the two modal dialogs uses the format of verb + noun, whether it is a declarative sentence or a question sentence
✅ Recommended usage❌ Deprecated usage
Edit ticketEdit
Delete form?Are you sure you want to delete form?
  • The operation buttons of the two modal dialog boxes only need to use the verbs in the title under the premise of ensuring that the title description is clear
✅ Recommended usage❌ Deprecated usage
EditEdit ticket
  • Text specification for imperative Modal
    • Give a specific explanation to the title, do not repeat the information of the title
    • Make sure users know how to act if necessary

Design Tokens

These are the component's internal Sass variables and cannot be overridden. To customize styles, override the --semi-* CSS variables (see the Design Token page) or write unlayered CSS rules.
Sass variableValueUsage
$animation_duration-modal-show120ms弹窗打开-动画持续时间
$animation_function-modal-showcubic-bezier(0.215, 0.61, 0.355, 1)弹窗打开-过渡曲线
$animation_delay-modal-show0ms弹窗打开-延迟时间
$animation_duration-modal-hide120ms弹窗关闭-动画持续时间
$animation_function-modal-hidecubic-bezier(0.215, 0.61, 0.355, 1)弹窗关闭-过渡曲线
$animation_delay-modal-hide0ms弹窗关闭-延迟时间
$animation_duration-modal_mask-show90ms弹窗打开时-蒙层颜色-动画持续时间
$animation_function-modal_mask-showcubic-bezier(0.215, 0.61, 0.355, 1)弹窗打开时-蒙层颜色-过渡曲线
$animation_delay-modal_mask-show0ms弹窗打开时-蒙层颜色-延迟时间
$animation_duration-modal_mask-hide90ms弹窗关闭时-蒙层颜色-动画持续时间
$animation_function-modal_mask-hidecubic-bezier(0.215, 0.61, 0.355, 1)弹窗关闭时-蒙层颜色-过渡曲线
$animation_delay-modal_mask-hide0ms弹窗关闭时-蒙层颜色-延迟时间
$animation_transform_scale-modal_content-open0.7弹窗打开时-缩放比例
$animation_opacity-modal_content-open0弹窗打开时-起始透明度
$animation_transform_scale-modal_content-close0.7弹窗关闭时-缩放比例
$animation_opacity-modal_content-close0弹窗关闭时-起始透明度
$animation_opacity-modal_mask-open0弹窗打开时-蒙层起始透明度
$animation_opacity-modal_mask-close0弹窗关闭时-蒙层起始透明度
$color-modal-bgvar(--semi-color-bg-2)模态框背景颜色
$color-modal_mask-bgvar(--semi-color-overlay-bg)模态框蒙层颜色
$color-modal_main-textvar(--semi-color-text-0)模态框文字颜色
$color-modal_info-iconvar(--semi-color-info)模态框信息图标颜色
$color-modal_primary-iconvar(--semi-color-primary)模态框主要图标颜色
$color-modal_success-iconvar(--semi-color-success)模态框成功图标颜色
$color-modal_danger-iconvar(--semi-color-danger)模态框危险图标颜色
$color-modal_warning-iconvar(--semi-color-warning)模态框警告图标颜色
$color-modal_content-bordervar(--semi-color-border)模态框描边颜色
$color-modal_header-bgtransparent模态框 header 背景填充色
$color-modal_footer-bgtransparent模态框 footer 背景填充色
$spacing-modal-marginY80px模态框距容器顶部外边距
$spacing-modal-marginXauto模态框水平外边距(默认居中)
$spacing-modal_mask-top0模态框蒙层顶部位置
$spacing-modal_mask-right0模态框蒙层右侧位置
$spacing-modal_mask-bottom0模态框蒙层底部位置
$spacing-modal_mask-left0模态框蒙层左侧位置
$spacing-modal_content_withicon-marginLeft36px模态框蒙层左侧位置
$spacing-modal_icon_wrapper-marginRight$spacing-base-tight模态框图标右侧外边距
$spacing-modal_wrap-top0
$spacing-modal_wrap-right0
$spacing-modal_wrap-bottom0
$spacing-modal_wrap-left0
$spacing-modal_title-margin0模态框标题外边距
$spacing-modal_content-paddingY0模态框内容垂直内边距
$spacing-modal_content-paddingX24px模态框内容水平内边距
$spacing-modal_header-marginY24px模态框标题垂直外边距
$spacing-modal_header-marginX0模态框标题水平外边距
$spacing-modal_header-paddingY0
$spacing-modal_header-paddingX0
$spacing-modal_body_wrapper-marginY24px
$spacing-modal_body_wrapper-marginX0
$spacing-modal_body-margin0模态框 body 外边距
$spacing-modal_body-padding0模态框 内容外Padding
$spacing-modal_footer-marginY24px模态框 footer 垂直外边距
$spacing-modal_footer-marginX0模态框 footer 水平外边距
$spacing-modal_footer-paddingY0
$spacing-modal_footer-paddingX0
$spacing-modal_footer_button-marginLeft$spacing-base-tight模态框 footer 按钮左侧外边距
$spacing-modal_confirm_header-marginBottom8px命令式调用模态框 header 底部外边距
$spacing-modal_confirm_icon_wrapper-marginRight$spacing-base-tight命令式调用模态框图标右侧外边距
$spacing-modal_content_fullscreen-top0px模态框内容全屏顶部位置
$width-modal_title100%模态框标题宽度
$width-modal_content100%模态框内容宽度
$height-modal_contentmax-content模态框内容高度
$width-modal_content-border1px模态框内容描边宽度
$width-modal_small448px模态框宽度 - 小
$width-modal_medium684px模态框宽度 - 中
$width-modal_large920px模态框宽度 - 大
$width-modal_full_widthcalc(100vw - 64px)模态框宽度 - 全屏
$radius-modal_contentvar(--semi-border-radius-large)模态框圆角大小
$radius-modal_content_fullscreen0模态框圆角大小 - 全屏
$radius-modal_footer0 0 5px 5px模态框 footer 圆角大小
$font-modal_header-fontSize$font-size-regular模态框 title 字号
$font-modal_header-fontWeight$font-weight-bold模态框 title 字重
$color-modal_header-bordertransparent模态框 header 底部描边颜色
$width-modal_header-border0模态框 header 底部描边宽度
$color-modal_footer-bordertransparent模态框 footer 顶部描边颜色
$width-modal_footer-border0模态框 footer 顶部描边宽度
$shadow-modal_contentvar(--semi-shadow-elevated)
$filter-modal_mask-bgnone
$filter-modal_content-bgnone

FAQ

  • Why the button texts in Modal.confirm are not internationalized even when I use LocaleProvider?

    A static Modal is rendered outside the component tree, so it cannot read the config from ConfigProvider or LocaleProvider. You could use Modal.useModal() and place the returned Holder where the config should be read, or use okText and cancelText to set the texts yourself.

  • Why is the spacing between title and content different under imperative and non-imperative calls?

    In the imperative call scenario, the title and content are more closely related, so expressing this strong correlation with a closer distance is in line with expectations. If users don't want this effect, they can do their own style overrides.