@react-lit/alert
TypeScript icon, indicating that this package has built-in type declarations

0.7.1 • Public • Published

@react-lit/alert

An alert is an element that displays a brief, important message in a way that attracts the user's attention without interrupting the user's task.

Dynamically rendered alerts are automatically announced by most screen readers, and in some operating systems, they may trigger an alert sound. It is important to note that, at this time, screen readers do not inform users of alerts that are present on the page before page load completes.

Installation

$ npm i @react-lit/alert
# or
$ yarn add @react-lit/alert

Example

import * as React from 'react';
import { Alert } from "@react-lit/alert";

function Example() {
  const [messages, setMessages] = React.useState([]);
  return (
    <div>
      <button
        onClick={() => {
          setMessages((prevMessages) =>
            prevMessages.concat([`Message #${prevMessages.length + 1}`])
          );
          setTimeout(() => {
            setMessages((prevMessages) => prevMessages.slice(1));
          }, 5000);
        }}
      >
        Add a message
      </button>
      <div>
        {messages.map((message, index) => (
          <Alert key={index}>{message}</Alert>
        ))}
      </div>
    </div>
  );
}

Development

(1) Install dependencies

$ npm i
# or
$ yarn

(2) Run initial validation

$ ./Taskfile.sh validate

(3) Run tests in watch-mode to validate functionality.

$ ./Taskfile test -w

This project was set up by @jvdx/core

Readme

Keywords

none

Package Sidebar

Install

npm i @react-lit/alert

Weekly Downloads

1

Version

0.7.1

License

MIT

Unpacked Size

10.7 kB

Total Files

7

Last publish

Collaborators

  • joelvoss