1.4.0 • Published 4 months ago

react-atom-toast v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

react-atom-toast

Tiny & Headless toast for React

Install

npm i react-atom-toast

Demo

Online

Usage

Basic

import { toast } from 'react-atom-toast'

// toast is headless and styleless, you'd customize it yourself
toast.setDefaultOptions({
  className: 'bg-red p-2 rounded',
})

toast.open('Hello, world!')

Transition

Transition is powered by react-transition-preset.

import { toast } from 'react-atom-toast'

toast({
  content: 'Hello, world!',
  transition: 'fade-up',
})

Single Instance

import { toast } from 'react-atom-toast'

toast({
  content: 'Hello, world!',
  maxCount: 1,
})

Options

duration

  • Type: number
  • Default: 2000

The duration of the toast.

className

  • Type: string

The class name of the toast.

react-atom-toast is headless, you need to style it yourself.

import { toast } from 'react-atom-toast'

toast.setDefaultOptions({
  className: 'bg-black bg-opacity-90 p-2 rounded',
})

transition

  • Type: PresetTransitionName | { name?: PresetTransitionName duration?: number exitDuration?: number }
  • Default: fade-up

The transition of the toast. Read react-transition-preset to learn more.

pauseOnHover

  • Type: boolean
  • Default: true

Prevent the toast from disappearing when hovering.

maxCount

  • Type: number
  • Default: 3

The maximum number of toasts that can be displayed at the same time.

If set to 1, the new toast will replace the old one.

gap

  • Type: number
  • Default: 16

The gap between toasts.

render

  • Type: (children: ReactNode) => ReactNode

Enhance the toast rendering. Useful for react context.

1.3.3

6 months ago

1.3.2

8 months ago

1.4.0

4 months ago

1.3.1

8 months ago

1.3.0

8 months ago

1.2.2

8 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago