From d0652a1be9744ac433d26c960a4253074bd40639 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 3 Jul 2017 16:09:28 -0700 Subject: Add new toasts component --- site/docs/4.1/components/toasts.md | 169 +++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 site/docs/4.1/components/toasts.md (limited to 'site/docs') diff --git a/site/docs/4.1/components/toasts.md b/site/docs/4.1/components/toasts.md new file mode 100644 index 000000000..df5d2e827 --- /dev/null +++ b/site/docs/4.1/components/toasts.md @@ -0,0 +1,169 @@ +--- +layout: docs +title: Toasts +description: Push notifications to your visitors with a toast, a lightweight and easily customizable alert message. +group: components +toc: true +--- + +Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They're built with flexbox, so they're easy to align and position. + +## Examples + +A basic toast can include a header (though it doesn't strictly need one) with whatever contents you like. The header is also `display: flex`, so `.mr-auto` and `.ml-auto` can be used for easy pushing of content, as well as all our flexbox utilities. + +
+{% capture example %} +
+
+ + Bootstrap + 11 mins ago +
+
+ Hello, world! This is a toast message. +
+
+{% endcapture %} +{% include example.html content=example %} +
+ +They're slightly translucent, too, so they blend over whatever they might appear over. For browsers that support `backdrop-filter`, we'll also attempt to blur the elements under a toast. + +
+{% capture example %} +
+
+ + Bootstrap + 11 mins ago +
+
+ Hello, world! This is a toast message. +
+
+{% endcapture %} +{% include example.html content=example %} +
+ +Plus, they'll easily stack. + +
+{% capture example %} +
+
+ + Bootstrap + just now +
+
+ See? Just like this. +
+
+ +
+
+ + Bootstrap + 2 seconds ago +
+
+ Heads up, toasts will stack automatically +
+
+{% endcapture %} +{% include example.html content=example %} +
+ +## Accessibility + +Toasts are intended to be small interruptions to your visitors or users, so to help those on screen readers, you should wrap your toasts in an [`aria-live` region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions). This allows screen readers the ability to see suggested interruptions without any visual cues. + +{% highlight html %} +
+
...
+
+{% endhighlight %} + +## Placement + +Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you're only ever going to show one toast at a time, put the positioning styles right on the `.toast.` + +
+{% capture example %} +
+
+
+ + Bootstrap + 11 mins ago +
+
+ Hello, world! This is a toast message. +
+
+
+{% endcapture %} +{% include example.html content=example %} +
+ +For systems that generate more notifications, consider using a wrapping element so they can easily stack. + +
+{% capture example %} +
+ +
+ + +
+
+ + Bootstrap + just now +
+
+ See? Just like this. +
+
+ +
+
+ + Bootstrap + 2 seconds ago +
+
+ Heads up, toasts will stack automatically +
+
+
+
+{% endcapture %} +{% include example.html content=example %} +
+ +You can also get fancy with flexbox utilities. + +
+{% capture example html %} +
+ +
+ + +
+
+ + Bootstrap + 11 mins ago +
+
+ Hello, world! This is a toast message. +
+
+
+
+{% endcapture %} +{% include example.html content=example %} +
-- cgit v1.2.3