React-toastify: CSS Padding for toasts

Created on 5 Dec 2017  路  3Comments  路  Source: fkhadra/react-toastify

Hi there,

I'm having some problems adding a bit more padding to the left and right of text in toast notifications. I tried adding it through toastClassName (as shown below), but it doesn't change the size of the toast container (resulting in a line break in the toast notification). Is there another way I should be doing this?

Thanks

<ToastContainer
    toastClassName="toast"
    position="bottom-center"
    autoClose={5000}
    hideProgressBar
    newestOnTop={false}
    closeOnClick />
.toast {
    padding-left: 30px !important;
    padding-right: 30px !important;
}
question

Most helpful comment

This seems to not work anymore. Is there a new way to customize the styling?

All 3 comments

Hello @garethwarry,

The ToastContainer width is fixed to 320px by default. You could increase it via the style helper:

import { style } from "react-toastify";
style({
  width: "350px"
});

The position property of the ToastContainer is fixed so it's hard to have a dynamic width for the toast.

I think that I need to review the implementation a bit and use max-width/min-width so the toast width will expand till it reaches max width

Thanks for the quick response! That solved the problem.

This seems to not work anymore. Is there a new way to customize the styling?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prmichaelsen picture prmichaelsen  路  5Comments

fkhadra picture fkhadra  路  4Comments

giocodes picture giocodes  路  3Comments

NoMercy235 picture NoMercy235  路  5Comments

JakubKoralewski picture JakubKoralewski  路  4Comments