# Alert Component ![alert](alert.gif) A toast-like alert notification that slides into view at the top of the screen when rendered, and slides back out of view when the "X" button is clicked/pressed. ## Usage ```javascript import { Alert } from "tailwindcss-stimulus-components" application.register('alert', Alert) ``` To customize the appearance of alerts based on the kind of alert it is, you can do something like this in: `app/helpers/application_helper.rb` ```ruby module ApplicationHelper def tailwind_classes_for(flash_type) { notice: "bg-green-400 border-l-4 border-green-700 text-white", error: "bg-red-400 border-l-4 border-red-700 text-black", }.stringify_keys[flash_type.to_s] || flash_type.to_s end end ``` And then add something like this either directly in the layout file, or in a partial that's rendered directly by the layout: ```html

Stimulus is the JS of the future!

``` Alerts are set up to slide into view from the top-right side of the screen. Clicking on the "X" button will cause the alert to slide back out of view and be removed from the DOM. ## Options - `data-alert-dismiss-after-value` can be provided to make the alert dimiss after x miliseconds. Default is `undefined`. - `data-alert-show-delay-value` can be set to tell the alert to show itself after x miliseconds. Defaults to `0` miliseconds.