Code Monkey home page Code Monkey logo

Comments (8)

timolins avatar timolins commented on May 30, 2024 3

Yes, you can change the z-index, for both the container or the toasts.

<Toaster
  containerStyle={{
	 zIndex: 9999 // For the container
  }}
  toastOptions={{
    style: {
      zIndex: 9999 // For toasts
    },
  }}
/>

from react-hot-toast.

joriswitteman avatar joriswitteman commented on May 30, 2024 3

Got around it by lowering other z indexes.

from react-hot-toast.

jorisw avatar jorisw commented on May 30, 2024 2

However toast.custom()'s second parameter does not accept a containerStyle property:

image

The styles that I apply myself to the top-level DOM node that my <Notification /> component produces, does not help, as the container produced one level above, by react-hot-toast, sets a z-index: 9999, which I can't seem to override.

Even this doesn't work for me:

    toast.custom(<div style={{ zIndex: 20000, backgroundColor: 'red' }} />)

... The top level container of react-hot-toast keeps z-index: 9999.

from react-hot-toast.

ZachHaber avatar ZachHaber commented on May 30, 2024 1

It's actually way more complicated than it needs to be. I couldn't figure out a way to set up the default Toaster component to use a className or a style.

Essentially, you need to Portal the Toaster into the body, and then set the Toaster to have filter: unset. Since we can't supply a style/class to the Toaster, I put a div around it to get rid of the blur.

Relevant code:

    <Portal open>
      <div style={{ filter: "unset" }}>
        <Toaster />
      </div>
    </Portal>

Running example:
https://codesandbox.io/s/suir-dimmer-hot-toast-ek2nb?file=/index.js

from react-hot-toast.

jorisw avatar jorisw commented on May 30, 2024

What if you're using toast.custom() ? I still get a container with z-index: 9999, that I need to increase.

The style option doesn't seem to work. Probably we need a containerStyle option?

from react-hot-toast.

timolins avatar timolins commented on May 30, 2024

Yes, you can use container styles or manually add your zIndex to your custom component.

toast.custom(<div style={{ zIndex: 9999 }}> {/ * Custom* /} </div>)

from react-hot-toast.

jorisw avatar jorisw commented on May 30, 2024

If the container element that react-hot-toast adds to the body, had an id or class name, at least I could override it using some global CSS and !important. But it's pretty much unselectable through CSS:

image

from react-hot-toast.

sanelaxm avatar sanelaxm commented on May 30, 2024

However toast.custom()'s second parameter does not accept a containerStyle property:

image

The styles that I apply myself to the top-level DOM node that my <Notification /> component produces, does not help, as the container produced one level above, by react-hot-toast, sets a z-index: 9999, which I can't seem to override.

Even this doesn't work for me:

    toast.custom(<div style={{ zIndex: 20000, backgroundColor: 'red' }} />)

... The top level container of react-hot-toast keeps z-index: 9999.

Were you able to get around this?

from react-hot-toast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.