确认模态框中的按钮样式

huangapple go评论78阅读模式
英文:

buttons styling in confirm Modal

问题

这个项目包含许多接口,其中包括一个用于上传图片的接口,还有一个用于确认删除图片操作的删除按钮。

在图片上可以看到有两个按钮,但我不知道如何为这些按钮添加样式,我需要为“buttons”添加右边距(marginRight)。

如何解决这个问题?

const onGalleryFileRemove = (_file: UploadFile<any>) => {
    const { confirm } = Modal;

    return new Promise<boolean>((resolve, reject) => {
        confirm({
            title: <h3 style={{ marginLeft: '3rem' }}>{formatMessage({ id: 'confirmationDeletePicture' })}</h3>,
            icon: <ExclamationCircleOutlined style={{ float: 'right' }} />,
            onOk: () => {
                resolve(true);
            },
            onCancel: () => {
                reject(true);
            }
        });
    });
};

确认模态框中的按钮样式

英文:

I have project and this project contains many of interfaces, and among these interfaces, there are interface to upload image, and i have delete button on this image to confirm delete image operation,

确认模态框中的按钮样式

and as u can see on the image, there are two buttons, i don't know how can put style to these buttons, i need to put marginRight to "buttons"

how can i solve the problem?

const onGalleryFileRemove = (_file: UploadFile&lt;any&gt;) =&gt; {
        const { confirm } = Modal

        return new Promise&lt;boolean&gt;((resolve, reject) =&gt; {
            confirm({
                title: &lt;h3 style={{ marginLeft: &#39;3rem&#39; }}&gt;{formatMessage({ id: &#39;confirmationDeletePicture&#39; })}&lt;/h3&gt;,
                icon: &lt;ExclamationCircleOutlined style={{ float: &#39;right&#39; }} /&gt;,
                onOk: () =&gt; {
                    resolve(true)
                },
                onCancel: () =&gt; {
                    reject(true)
                }
            })
        });
    };

答案1

得分: 1

你可以在okButtonPropscancelButtonProps属性中传递样式。

Modal.confirm({
	content: 'Hello World',
	cancelButtonProps: {
		style: {
			marginRight: '10px'
		}
	},
	okButtonProps: {
		style: {
			marginRight: '10px'
		}
	}
});
英文:

You can pass style in okButtonProps and cancelButtonProps props.

Modal.confirm({
	content: &#39;Hello World&#39;,
	cancelButtonProps: {
		style: {
			marginRight: &#39;10px&#39;
		}
	},
	okButtonProps: {
		style: {
			marginRight: &#39;10px&#39;
		}
	}
});

huangapple
  • 本文由 发表于 2023年2月18日 20:51:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75493465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定