Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-message-block

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-message-block

An easy to use, simple multi-purpose react messages. Ability to show success, error, warn and info messages by default. Custom Message Styling supported

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Doing a React POC or building a production application? react-message-block is an easy to use package for showing success/error/warn/info/custom message blocks.

Features

  • Lightweight
  • Out of the box message stylings
  • Custom Styling Options

Installation

With Yarn

yarn add react-message-block

With npm

npm i --save react-message-block

Documentation

You could view the documentation in Github Page as well.

Usage

react-message-block is compatible with both Class and Functional React Components.

Basic Usage

import Message from 'react-message-block';
const App = () => {
    return (
        <div>
            <Message text = {'Congrats! You have installed this plugin'} />
        </div>
    )
}

View Example on Sandbox

Available Custom Props

By default, react-message-block comes up with the following properties. You could use the following to customize your message block out of the box.

PropOptionalDefaultPossible ValuesDescription
textYesAny StringDisplay Message
typeYesinfoplain | info | success | error | warnTo show Loading Message
onCloseYes Callback func Callback function to close the message block. Close Icon will appear along with the message block
styleYes Custom Style Object To apply user defined styles
alignYescenter center | left | right To align message text

Example

Custom HTML Layout

Not happy with the one line message? You could always pass children within the Message component to display your custom message layout.

<Message type = 'info'>
    <h4>Message Heading</h4>
    <p>This is the message body</h4>
</Message>
<Message type = 'error'>
    <h4>Please check the following fields</h4>
    <ul>
      <li>Email is not valid</li>
      <li>Password and Confirm Password does not match</li>
      <li>Phone Number is already registered</li>
    </ul>
</Message>

View Example on Sandbox

onClose

Many times, you would want to provide the feasibility of dismissing a message block. You could achieve it by passing onClose callback function as prop to the component.

<Message 
  text = 'Something went wrong' 
  type = 'error' 
  onClose = {handleClose} 
>

View Example on Sandbox

No Background! Just the message

Want to show just the message without a background? Use type="plain
In most projects, you would want to use this while showing "No Content Messages"

<Message 
  text = 'No Content Available' 
  type = 'plain' 
  onClose = {handleClose} 
>

What's Coming Up

  • Icon for Messages
  • Auto Hiding Message after N seconds

Author

Nijin Vinodan

Keywords

FAQs

Package last updated on 17 May 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc