ant design中notification组件的样式修改

将message和description的文字改成橘色

import { Button, notification, Space } from 'antd';

const openNotificationWithIcon = type => {
  notification[type]({
    message: 'Notification Title',
    description:
      'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
  });
};

ReactDOM.render(
  <Space>
    <Button onClick={() => openNotificationWithIcon('success')}>Success</Button>
    <Button onClick={() => openNotificationWithIcon('info')}>Info</Button>
    <Button onClick={() => openNotificationWithIcon('warning')}>Warning</Button>
    <Button onClick={() => openNotificationWithIcon('error')}>Error</Button>
  </Space>,
  mountNode,
);

 

classname和style都行 

const openNotification = () => {
  notification.open({
    message: 'Notification Title',
    description:
      'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
    className: 'custom-class',  //类名
    style: {
      width: 600, //样式
    },
  });
};

 

通过给notification的配置项添加自定义的className,代码如下:

  openNotificationWithIcon = (type) => {
    notification[type]({
      message: '主要标题',
      description: '描述信息',
      className: 'theme-color',
      style: {
        color: 'orange',
      },
    });
  };

css代码:

.theme-color .ant-notification-notice-message {
  color: orange;
}
.theme-color .ant-notification-notice-description {
  color: orange;
}

 

style行内的话只对description 描述信息有作用 ,通过className: 'theme-color',message和description都会受到影响   谢啦哈