To modify the button color in antd Modal, you can use the "buttonProps" property on the button component. This property takes an object with any valid button props, such as "style" or "className". Here's an example code:
import { Modal, Button } from 'antd';
const ExampleModal = () => {
const handleOk = () => {
console.log('Clicked OK');
};
const handleCancel = () => {
console.log('Clicked cancel');
};
return (
<Modal
title="Basic Modal"
visible={true}
onOk={handleOk}
onCancel={handleCancel}
footer={[
<Button key="cancel" onClick={handleCancel}>
Cancel
</Button>,
<Button
key="submit"
type="primary"
onClick={handleOk}
buttonProps={{ style: { backgroundColor: "red" } }}
>
Submit
</Button>,
]}
>
<p>Some contents...</p>
</Modal>
);
};
In this example, the primary button's background color is set to red using the "style" property of the "buttonProps" object.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-07-01 11:00:00 +0000
Seen: 7 times
Last updated: Mar 22
Is it impossible to modify the color of button text on Android?
In Angular, how can a mat cross button be aligned to the right-most position within a div?
How can I detect the fullscreen button click event of an HTML5 video?
How can I create an HTML button that sends data to a different URL?
How can we use the Pywinauto library to automate the control of Proton VPN?
How can a button be utilized to display and hide the matplotlib live graph?
How can I activate a button using Angular Material?
How can key and value be saved in admin setting using Opencart 3?
How can I utilize the export default function to construct buttons in react version 16?