Code Monkey home page Code Monkey logo

Comments (7)

timolins avatar timolins commented on May 31, 2024 26

It definitely would be great to have a built-in dismiss option. I still want to try out a couple of options to figure out what works best on mobile & desktop. I'm currently thinking of tap, swipe or a button to dismiss.

from react-hot-toast.

asp2809 avatar asp2809 commented on May 31, 2024 9

According to me, in the ideal case scenario, it should be a swipe on the mobile and "X" button as suggested by @Twixes on the web as both of these are the most convenient way according to me.

from react-hot-toast.

sparkplug0025 avatar sparkplug0025 commented on May 31, 2024 8

+1 for swiping on mobile. Does anyone have an example?

from react-hot-toast.

christian-ek avatar christian-ek commented on May 31, 2024 3

If anyone like me googled to find a way to do this here is an example:

const duration = 10000;
const toastContent = (t) => (
  <span>
    {notification.message}
    <button
      onClick={() => toast.dismiss(t.id)}
      className="close-button"
      type="button"
    >
      ×
    </button>
  </span>
);
toast.success(toastContent, { duration });

CSS:

.close-button {
  position: absolute;
  top: 3px;
  right: 5px;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 0px;
  line-height: 1;
  color: #333;
}

from react-hot-toast.

iamjatinchauhan avatar iamjatinchauhan commented on May 31, 2024

It should be made available, to have an option to set value true or false for "X" button. There could also be an option to set each notification visible time(duration).

from react-hot-toast.

lsbyerley avatar lsbyerley commented on May 31, 2024

@mrjatinchauhan I agree, an "X" button/icon should be an available opt-in option.

There is currently an option to set the duration. You can set the default duration for all toasters or for each type individually.

from react-hot-toast.

jhonatanAlanFerreira avatar jhonatanAlanFerreira commented on May 31, 2024

If anyone like me googled to find a way to do this here is an example:

const duration = 10000;
const toastContent = (t) => (
  <span>
    {notification.message}
    <button
      onClick={() => toast.dismiss(t.id)}
      className="close-button"
      type="button"
    >
      ×
    </button>
  </span>
);
toast.success(toastContent, { duration });

CSS:

.close-button {
  position: absolute;
  top: 3px;
  right: 5px;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 0px;
  line-height: 1;
  color: #333;
}

Is it possible to do something similar but using toast.promisse() ?
It seems like it only allow plaintext, not html.

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.