summaryrefslogtreecommitdiffstats
path: root/bootstrap-v5-toaster/README.md
blob: c0a49b02ae78ebe231c8ac6594578558f1466ba7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Bootstrap v5 Toaster

Create Bootstrap 5 toasts programatically

![alt text](https://github.com/ivarlovlie/bootstrap-v5-toaster/raw/master/toasts.png "How the toasts look")

## Example:

```html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href="bootstrap.css" />
        <title>Bootstrap 5 Toaster</title>
    </head>

    <body>
        <script src="bootstrap.js"></script>
        <script src="toaster.js"></script>
        <script>
            const toasterOptions = {
                hideAfter: 3500,
                position: "top-right",
            };
            const toaster = new Toaster(toasterOptions);
            toaster.error("Error", "Something failed");
            toaster.success("Success", "Something succeded", false);
            toaster.info("You should know", "Something informational", 5000);
        </script>
    </body>
</html>
```

`toasterOptions` is optional and the values in the example are the default values. \
`position` can be one of the following: "top-right top-left bottom-right bottom-left".

All display functions have the following parameters and options: \
| Parameter | Value | Default |
| ------------- |:-------------:| -----:|
| `title` | required string | undefined |
| `message` | optional string | "" |
| `autohide` | boolean or an int specifying `hideAfter` | true |