Constructor
new Toast()
Properties:
Name | Type | Description |
---|---|---|
key |
string | an I18n key of the message to show in the toast. When you generate the toast's HTML on the server, do not set key. Then, when you need to display the toast, use JavaScript to set the key. This will trigger its behavior as described above. |
Example
<style>
brut-toast {
display: none;
}
brut-toast[key] {
display: block;
}
</style>
<brut-i18n-translation key="toast.saved">Save successful</brut-i18n-translation>
<brut-toast>
<div>
<output></output>
<button>Close</button>
</div>
</brut-toast>
<!-- now, if you set the key to "toast.saved", the HTML will be changed as follows: -->
<brut-toast key="toast.saved">
<div>
<output>
<brut-message key="toast.saved" role="status" aria-live="polite" aria-atomic="true">
Save successful
</brut-message>
</output>
<button>Close</button>
</div>
</brut-toast>