react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

Close button overlays toast text

Open cduff opened this issue 10 months ago • 3 comments

For example:

image

Since v11 the close button is absolutely positioned. However, with its default position and with the default toast padding, it's possible for the close button to overlay toast text. This didn't happen <v11.

Should the default styling avoid this?

cduff avatar Jan 15 '25 00:01 cduff

Hey @cduff, I couldn't reproduce it, normally the content has a padding to avoid that. Could it be that you have some custom css rules applied? May I ask you to reproduce the issue on stackblitz? Thank you Screenshot 2025-01-15 at 08 18 39

fkhadra avatar Jan 15 '25 13:01 fkhadra

Hey @cduff, I couldn't reproduce it, normally the content has a padding to avoid that. Could it be that you have some custom css rules applied? May I ask you to reproduce the issue on stackblitz? Thank you Screenshot 2025-01-15 at 08 18 39

Hi @fkhadra, thanks for your response on this.

Try this StackBlitz:

https://stackblitz.com/edit/vitejs-vite-rhrg1ybn?file=src%2FApp.tsx

Image

cduff avatar Jan 16 '25 11:01 cduff

Looks like the padding is 14px https://github.com/fkhadra/react-toastify/blob/a6250d5b918b89eb84a9f1151fda8f9f426a47e7/src/style.css#L130

But the button is 20px wide and 25px tall (3px come from the line-height) https://github.com/fkhadra/react-toastify/blob/a6250d5b918b89eb84a9f1151fda8f9f426a47e7/src/style.css#L298-L299 https://github.com/fkhadra/react-toastify/blob/a6250d5b918b89eb84a9f1151fda8f9f426a47e7/src/style.css#L322-L323

I would probably update the SVG so it's square

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
  <path d="m9.48 8 3.75 3.75-1.48 1.48L8 9.48l-3.75 3.75-1.48-1.48L6.52 8 2.77 4.25l1.48-1.48L8 6.52l3.75-3.75 1.48 1.48L9.48 8z"/>
</svg>

Set the height and width of the SVG to 14px. Update the button's line-height to 0; and update the --toastify-toast-padding to 16px.

Then the toast will look like this

new padding toast

The extra s' were added to get as close to the close button as I could.

Link2Twenty avatar Feb 21 '25 16:02 Link2Twenty