Use payload's own toast notification inside custom React components

default discord avatar
hayskapoy
2 months ago
7

How do we show a toast notification with the exact same styles as the default? Thanks!

  • default discord avatar
    Tinouti
    2 months ago

    @hayskapoy did you figure out how to do this by any chance?

  • default discord avatar
    hayskapoy
    2 months ago

    Unfortunately not

  • default discord avatar
    Alessio 🍣
    2 months ago

    Would be interested in that too. Maybe it's better building an interface for toasts in payload which can be used externally by plugins, instead of using react-toastify directly?



    @jmikrut what do you think? Will build it if you think that's a good idea!

  • default discord avatar
    KasparTr
    last month

    @Alessio 🍣 do you have examples of how you used react-toastify in your Payload app?

  • default discord avatar
    Alessio 🍣
    last month

    You can check how it's done in payload, e.g.:

    https://github.com/AlessioGr/payload/blob/extra_attribute_for_fields/src/admin/components/elements/Autosave/index.tsx#L65

    but I didn't get it to work in a payload app (e.g. through a plugin) like that. Not sure why, maybe it's not part of the ToastContainer

  • discord user avatar
    denolfe
    Payload Team
    last month

    This would likely fall under this Priority 1 Roadmap item:

    https://github.com/payloadcms/payload/discussions/293

    @hayskapoy Maybe add a comment on that calling out the toast notifications specifically

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.