New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

reactjs-alert

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-alert

reactjs-alert is a lightweight and customizable alert component for React.js applications. Easily create success, warning, error, or info alerts with a clean UI, custom colors, and auto-close functionality. Ideal for enhancing user notifications and impro

latest
Source
npmnpm
Version
2.5.2
Version published
Maintainers
0
Created
Source

reactjs-alert: Lightweight Customizable React.js Alert Component

npm NPM npm Dependents (via libraries.io) npm collaborators

Simple, lightweight, customizable React.js alert component for better user notifications.
An advance and unique alert for React.js applications - reactjs-alert.

reactjs-alert is a simple, lightweight, flexible and customizable React.js alert component that helps developers create customizable alerts with ease. It supports multiple alert types like success, warning, error, and info, and comes with options for custom colors, auto-close, and quotes. Ideal for improving user engagement and enhancing notification systems in React applications. Get started in minutes with npm install reactjs-alert.

🚀 Installation

Install the package via npm:

npm install --save reactjs-alert

Or with shorthand:

npm i reactjs-alert

📫 Available Alert Types

Alert TypeDescriptionColorUsage Syntax
SuccessIndicates a successful action or completion.#00c12csuccess
WarningCautions the user about a potential issue.#ff9900warning
ErrorIndicates a serious issue that requires attention.#de1327error
CriticalHighlights a severe issue that demands immediate action e.g. system outages, security concerns, or urgent messages.#a71d31critical
ConfirmationProvides feedback when a user confirms an action.#2a8a2econfirm
NoticeUsed for maintenance updates or informational notices.#51bfd0notice
InformationDisplays general information or guidance.#00b0ffinfo

🧩 Example Usage with Props

<ReactJsAlert
  status={true}
  type="error"
  title="Oops! Something went wrong."
  color="#ff4d4f"
  isQuotes={true}
  quote="Please try again later."
  Close={() => setStatus(false)}
/>

⚙️ Available Props

Prop NameTypeDescriptionRequired
statusBooleanControls alert visibility (true / false)Yes
titleStringMain message text displayed as titleYes
typeStringAlert type: choose one of the option from Available Alert TypesYes
colorStringCustom background color (Hex code e.g. #de1327)No
isQuotesBooleanDisplays additional quote text (true / false)No
quoteStringThe additional quote message if isQuotes = trueNo
buttonStringCustom button text (e.g. "Try Again", "Submit")No
autoCloseInNumberAutomatically close the alert after X millisecondsNo
Close (method)FunctionCallback method to manually close the alertYes

📸 Example Screenshot

Example Screenshot

📋 How to Use

reactjs-alert provides an intuitive way to display alerts for different types like success, warning, error, and info.

Simply import the component and configure it using the available props.

Class Component Example

import React, { Component } from "react";
import ReactJsAlert from "reactjs-alert";

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      type: "success",
      status: true,
      title: "Hey! This is a success alert.",
    };
  }

  render() {
    return (
      <div>
        <ReactJsAlert
          status={this.state.status}
          type={this.state.type}
          title={this.state.title}
          Close={() => this.setState({ status: false })}
        />
      </div>
    );
  }
}

Functional Component Example

import React, { useState } from "react";
import ReactJsAlert from "reactjs-alert";

export default function App() {
  const [status, setStatus] = useState(false);
  const [type, setType] = useState("success");
  const [title, setTitle] = useState("This is a success alert");

  return (
    <div>
      <button
        onClick={() => {
          setStatus(true);
          setType("success");
          setTitle("This is a success alert");
        }}
      >
        Show Alert
      </button>

      <ReactJsAlert
        status={status}
        type={type}
        title={title}
        Close={() => setStatus(false)}
      />
    </div>
  );
}

🔗 Peer Dependencies

Ensure these dependencies are present in your project:

"peerDependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
}

💻 Example with Multiple Alerts

Class Component Example

import React, { Component } from "react";
import ReactJsAlert from "reactjs-alert";

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      type: "error",
      status: true,
      title: "Oops! Something went wrong.",
    };
  }

  render() {
    return (
      <div>
        <ReactJsAlert
          status={this.state.status}
          type={this.state.type}
          title={this.state.title}
          Close={() => this.setState({ status: false })}
        />
      </div>
    );
  }
}

Functional Component Example

import React, { useState } from "react";
import ReactJsAlert from "reactjs-alert";

export default function App() {
  const [status, setStatus] = useState(false);
  const [type, setType] = useState("");
  const [title, setTitle] = useState("");

  return (
    <div>
      <button
        onClick={() => {
          setStatus(true);
          setType("info");
          setTitle("This is an info alert!");
        }}
      >
        Show Info Alert
      </button>

      <ReactJsAlert
        status={status}
        type={type}
        title={title}
        isQuotes={true}
        quote="This is an example of a ReactJs alert."
        Close={() => setStatus(false)}
      />
    </div>
  );
}

🤝 Contributing

Contributions are welcome! If you have suggestions, improvements, or feature requests, feel free to fork the repository, raise issues, or submit pull requests.

⭐ Support

If you find this package helpful, consider giving it a ⭐ on GitHub.

📢 Follow Me

For updates, projects, and announcements, follow me on Linkedin.

You can also follow me on Twitter.

Built with ❤️ by Sourav Dutta 😊

Happy Coding! 🚀

Keywords

reactjs-alert

FAQs

Package last updated on 18 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts