Friday, October 17, 2025
HomeLanguagesReact Suite Message Props & Methods

React Suite Message Props & Methods

React Suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application.

In this article, we’ll learn about React Suite Message Props & Methods. A message component is used to show important tips on a page.

Message Props:

  • children: It provides the description information for the message.
  • classPrefix: It is used to denote the prefix of the component CSS class.
  • closable: It gives whether to close the message box.
  • full: It fills the message container.
  • header: It provides the title of the message.
  • onClose: It is called after the message is closed.
  • showIcon: It is used whether to display an icon or not.
  • type: It displays the type of message box. Four types include info, warning, error, and success.

useToaster Method (Hook): The useToaster is a react hook or method used for creating and managing the toasters in web applications.

  • toaster.push(): It is used to push a message and return a unique key.
  • toaster.remove(): It is used to remove a message by a key.
  • toaster.clear(): It is used to close all messages.

Syntax:

import { Message } from "rsuite";

Function App() {
    return (
        <Message closable type="warning" >
            ...
        </Message>
    );
}

Creating React Application And Installing Module:

Step 1: Create a React application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

 

Example 1: Below example demonstrates the useToaster.push method of Message Prop.

Javascript




import { Button, Message, useToaster } from "rsuite";
import "rsuite/dist/rsuite.min.css";
  
export default function App() {
  
    const toaster = useToaster();
  
    const message = (
        <Message showIcon type={'success'}>
            Hey Geek! Welcome to neveropen.
        </Message>
    );
  
    return (
        <center>
            <div>
                <h2>neveropen</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Message Props and Methods
                </h4>
  
                <div style={{ marginTop: 20, width: 400 }}>
                    <Button onClick={() => toaster.push(message)}>
                        Push
                    </Button>
                </div>
            </div>
        </center>
    );
}


Output:

 

Example 2: Below example demonstrates the useToaster.remove method of Message Prop.

Javascript




import { Button, Message, useToaster } from "rsuite";
import "rsuite/dist/rsuite.min.css";
  
export default function App() {
  
    const toaster = useToaster();
  
    const message = (
        <Message showIcon type={'success'}>
            Hey Geek! Welcome to neveropen.
        </Message>
    );
  
    return (
        <center>
            <div>
                <h2>neveropen</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Message Props and Methods
                </h4>
  
                <div style={{ marginTop: 20, width: 400 }}>
                    <Button onClick={() => toaster.push(
                        message, { placement: 'topEnd' }
                    )}>
                        Push
                    </Button>
                    <Button onClick={() => toaster.remove()}>
                        Remove
                    </Button>
                </div>
            </div>
        </center>
    );
}


Output:

 

Example 3: Below example demonstrates the useToaster.clear method of Message Prop.

Javascript




import { Button, Message, useToaster } from "rsuite";
import "rsuite/dist/rsuite.min.css";
  
export default function App() {
  
    const toaster = useToaster();
  
    const message = (
        <Message showIcon type={'info'}>
            You have been successfully logged in.
        </Message>
    );
  
    return (
        <center>
            <div>
                <h2>neveropen</h2>
                <h4 style={{ color: "green" }}>
                    React Suite Message Props and Methods
                </h4>
  
                <div style={{ marginTop: 20, width: 400 }}>
                    <Button onClick={() => toaster.push(
                        message, { placement: 'bottomCenter' }
                    )}>
                        Push
                    </Button>
                    <Button onClick={() => toaster.clear()}>
                        Clear
                    </Button>
                </div>
            </div>
        </center>
    );
}


Output:

 

Reference: https://rsuitejs.com/components/message/#props-amp-hooks

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS