question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to style different toast types globally ?

See original GitHub issue

` // Verification email sent if (status === ‘checkMail’) { toast.success(‘Please check your email’, { className: { color: ‘#343a40’, minHeight: ‘60px’, borderRadius: ‘8px’, background: ‘#2FEDAD’, boxShadow: ‘2px 2px 20px 2px rgba(0,0,0,0.3)’ }, progressClassName: css({ background: ‘#007aff’ }) }); }

// Verification Success
if (status === 'emailVerified') {
  toast.success('Thankyou, your email has been verified!', {
    className: {
      color: '#343a40',
      minHeight: '60px',
      borderRadius: '8px',
      background: '#2FEDAD',
      boxShadow: '2px 2px 20px 2px rgba(0,0,0,0.3)'
    },
    progressClassName: css({
      background: '#007aff'
    })
  });
}

// password updated 
if (status === 'passwordUpdated') {
  toast.success('Password has been updated!', {
    className: {
      color: '#343a40',
      minHeight: '60px',
      borderRadius: '8px',
      background: '#2FEDAD',
      boxShadow: '2px 2px 20px 2px rgba(0,0,0,0.3)'
    },
    progressClassName: css({
      background: '#007aff'
    })
  });
}

// ---------   Signup Fail Toaster
if (status === 'signupFail') {
  toast.error('User Already Exists!', {
    className: {
      color: '#fff',
      minHeight: '60px',
      borderRadius: '8px',
      boxShadow: '2px 2px 20px 2px rgba(0,0,0,0.3)'
    },
    progressClassName: css({
      background: '#007aff'
    })
  });
}

// ---------   Login Fail Toaster
if (status === 'fail') {
  toast.error('Wrong User name and password!', {
    className: {
      color: '#fff',
      minHeight: '60px',
      borderRadius: '8px',
      boxShadow: '2px 2px 20px 2px rgba(0,0,0,0.3)'
    },
    progressClassName: css({
      background: '#007aff'
    })
  });
}`

As you can see i have multiple toasters maily two types. one is success toaster and another is error. both types of toaster have same css i.e., all success toasters have same css and all error toasters share same css. how do i define global css for both type ? or how can i declare global css for different toaster types on <ToastContainer/>. I dont want to manage my css from style.css or any css file.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
fkhadracommented, Feb 27, 2018

Hello @sushmit-oodles,

It can be done easily with your own implementation as follow:

Edit v0lpr78prl

Cheers

6reactions
alexkhismatulincommented, Jul 23, 2019

@fkhadra could you attach a snippet as well cause the link to sandbox is broken? I believe this is a very common question but it’s not covered in docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to style | React-Toastify - GitHub Pages
Below, a list of the CSS classes used(classes used for animation and media query are omitted) ... The ToastContainer accept the following props...
Read more >
Using React-Toastify to style your toast messages
Styling your toast messages with React-Toastify ... This technique uses different colors for each toast message type to make it easier for ...
Read more >
How can I change the styles of the react-toastify popup ...
Easest way to define a custom method, which can take the type of notification, content, and toast options.
Read more >
What people put on their toast in 10 countries around the world
What people put on their toast in 10 countries around the world · France is well-known for mastering the simple toast. · In...
Read more >
Toasts · Bootstrap v5.0
You can stack toasts by wrapping them in a toast container, which will vertically add some spacing. Bootstrap just now. See? Just like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found