• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

342
Views
How to position antd notification - i want it to be centered

Im using this

export function notificationWithIcon(type, title, description, placement) {
  notification[type]({
    message: title,
    description: description,
    placement
  });
}

However, the only options are topRight, bottomRight, bottomLeft or topLeft

I would like it to appear in the center of my screen. Is there any way to achieve that

EDIT: I used Majid's idea and this is how it looks like now. It's still positioned a bit to the right

enter image description here

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on documentations:

A notification box can appear from the topRight, bottomRight, bottomLeft or topLeft of the viewport.

But you can customize it yourself with css classes:

.ant-notification-center {
  left: 50%;
  bottom: 50% !important;
  margin-right: 30%;
  transform: translate(-50%, -50%);
}

and use the notification same as following sample:

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Button, notification, Space } from "antd";
import { RadiusUpleftOutlined } from "@ant-design/icons";

const openNotification = (placement) => {
  notification.info({
    message: `Notification ${placement}`,
    duration: 10000,
    description:
      "This is the content of the notification. This is the content of the notification. This is the content of the notification.",
    placement
  });
};

ReactDOM.render(
  <div>
    <Space>
      <Button type="primary" onClick={() => openNotification("center")}>
        <RadiusUpleftOutlined />
        center
      </Button>
    </Space>
  </div>,
  document.getElementById("container")
);

Edit Placement - antd@4.18.6 (forked)

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error