# @toast-loadings/react

> Toast Loading for React.

Latest version **0.1.0** (published 2023-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @toast-loadings/react
pnpm add @toast-loadings/react
yarn add @toast-loadings/react
bun add @toast-loadings/react
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-10-10 |
| First published | 2023-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 2 |
| Unpacked size | 55.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | haoqichan |
| Maintainers | haoqichan |
| Keywords | toast, loading, toast loading, react loading, react toast loading |

## Links

- npm: https://www.npmjs.com/package/@toast-loadings/react
- npm.io page: https://npm.io/package/@toast-loadings/react

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-10-10

## README

# Toast Loading

Toast Loading for React.

- [English](README.md)
- [简体中文](README_zh.md)
- [Vue3](https://www.npmjs.com/package/@toast-loadings/vue3)

## Installation

```
$ npm i -save @toast-loadings/react
```

or

```
$ yarn add @toast-loadings/react
```

## Quick Start

```ts
import { resetDefaultOptions, setDefaultOptions, hideLoading, showLoading } from '@toast-loadings/react';

// reset global current default options
resetDefaultOptions();

// set global default options
setDefaultOptions({
  type: 'circular',
  duration: 10 * 1000,
  ...others
});

// Show Loading
showLoading('Loading...');

// Show Loading（with object）
showLoading({ position: 'bottom', message: 'Loading...' });

// Hide Loading
hideLoading();
```

## Options

```ts
interface Options {
  // The loading icon type ('circular', 'scale', 'spinner', 'spinner2'), defaults is 'spinner', and can be customized via the slot icon when the component is invoked
  type?: string;
  // Display position ('top', 'middle', 'bottom'), default is 'middle'
  position?: string;
  // Display duration, should be >= 0, default is 0
  duration?: number;
  // Whether to disable clicks on all elements during display
  forbidClick?: boolean;
  // Custom class name
  className?: string | object;
  // Custom z-index level. If not set, global auto-incrementing level(from 5000) will be used
  zIndex?: number;
  // Custom message
  message?: string;
  // Custom class name for message
  messageClassName?: string | object;
  // Custom style for message
  messageStyle?: string | object;
  // Whether to show loading icon, default is true
  showIcon?: boolean;
  // Custom color for loading icon
  iconColor?: string;
  // Custom size for loading icon
  iconSize?: string;
  // Custom class name for loading icon
  iconClassName?: string | object;
  // Custom style for loading icon
  iconStyle?: string | object;
}
```

## Component usage

```tsx
import React from 'react';
import {
  Circular,
  Scale,
  Spinner,
  Spinner2,
  ToastLoading
} from '@toast-loadings/react';

const App = () => {
  return (
    <div>
      <ToastLoading position="bottom" message="Loading..."/>
      <Circular color="#333" size="40px"/>
      <Scale color="#444" size="40px"/>
      <Spinner color="#555" size="40px"/>
      <Spinner2 color="#666" size="40px"/>
    </div>
  );
}

export default App;
```

## Example project

A React18 + TS example project.

### Project dir

```
$ cd example
```

### Project setup

```
$ npm install
```

or

```
$ yarn install
```

### Compiles and hot-reloads for development

```
$ npm run dev
```

or

```
$ yarn dev
```

---
_Source: https://npm.io/package/@toast-loadings/react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
