JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 106
  • Score
    100M100P100Q75178F
  • License MIT

Package Exports

  • react-toast-wnm

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-toast-wnm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-toast-wnm · GitHub license codecov

Demo

Check demo

Toast Hook Params

  • position options -> 'bottom-right' | 'bottom-center' | 'bottom-left' | 'top-left' | 'top-center' | 'top-right'.
  • type options -> 'default' | 'error' | 'warning' | 'success' | 'info'.
Params Description
autoDismiss boolean Default: true. Disable or enable dismiss autoclose toast.
backgroundColor string Default ''. Toast backgroundColor
borderRadius string Default 6px . Toast border toast.
children Object{actions, content} Optional. Toast content and action custom.
color string Default ''. Color text toast.
delay number Default 3000. The time until a toast will be dismissed automatically, in milliseconds.
enableAnimation bolean Default: true.
height string Default 104px. Toast height.
padding string Default 24px 32px. Toast padding.
position string Default bottom-right. Viewport place the toasts.
subtitle string Default ''. Toast title.
title string Default ''. Toast subtitle.
type string Default default. Type toast.
width string Default 456px. Toast width.

Default sample use

import { useToast } from 'react-toast-wnm'

const MyComponent = () => {
  const { toast } = useToast();

  return (
    <Button
      onClick={(): void => {
        toast({
          autoDismiss: true,
          enableAnimation: true,
          delay: 3000,
          type: 'success',
          borderRadius: '6px',
          position: 'bottom-right',
          height: '104px',
          padding: '24px 32px',
          subtitle: 'Default subtitle',
          title: 'Default title',
          width: '456px'
        });
      }}
    >
      Create my custom toast
    </Button>
  );
}

Custom sample use

import { useToast } from 'react-toast-wnm'

const CustomContent = (): JSX.Element => (
  <div className={myCustomContentStyles}>
    <div>My custom title</div>
    <div>My custom subtitle</div>
  </div>
);

//When you create a custom actions 
// component, a closeToast prop is injected into your component.
const CustomActions = ({ closeToast, color, backgroundColor }) => (
  <div className={myCustomActionsStyles}>
    <button style={{ backgroundColor, color }} onClick={closeToast}>
      Button label
    </button>
    <button style={{ backgroundColor, color }}>Other button</button>
  </div>
);

const MyComponent = () => {
  const { toast } = useToast();

  return (
    <Button
      onClick={(): void => {
        toast({
          delay: 5000,
          backgroundColor: '#fff',
          borderRadius: '6px',
          color: '#000',
          position: 'top-right',
          actions: (
            <CustomActions
              color='purple'
              backgroundColor='red'
            />
          ),
          content: <CustomContent />,
     
        });
      }}
    >
      Create my custom toast
    </Button>
  );
}