Skip to the page content

Toasts

Short notices that float over the page and go away.

Bootstrap reference

11 toast types

Basic toast

Bootstrap's own toast with a header and body, shown in place with .show. The header, border and close button all follow the palette.

Bootstrap
North territory 11 min ago
Crews closed the day with 38 of 41 visits complete.
Show code
<div class="toast show" role="status" aria-live="polite" aria-atomic="true">
  <div class="toast-header">
    <strong class="me-auto">North territory</strong>
    <small>11 min ago</small>
    <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  </div>
  <div class="toast-body">Crews closed the day with 38 of 41 visits complete.</div>
</div>

Stacked toasts

Bootstrap's .toast-container puts space between toasts that arrive together. Newest last, as Bootstrap stacks them.

Bootstrap
Deliveries 9:02 am
Supplies for car 7 arrived at the office.
On-call 9:05 am
Rory swapped Saturday's on-call with Connie.
Show code
<div class="toast-container position-static">
  <div class="toast show" role="status" aria-live="polite" aria-atomic="true">…</div>
  <div class="toast show" role="status" aria-live="polite" aria-atomic="true">…</div>
</div>

Custom content

Bootstrap toasts without a header: the close button sits in the body, or the body carries its own buttons under a divider.

Bootstrap
Credit note #2210 applied for $25.00.
Connie asked for Monday off. Two visits need cover.
Show code
<div class="toast align-items-center show" role="status" aria-live="polite" aria-atomic="true">
  <div class="d-flex">
    <div class="toast-body">Credit note #2210 applied for $25.00.</div>
    <button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
  </div>
</div>

<div class="toast show" role="status" aria-live="polite" aria-atomic="true">
  <div class="toast-body">
    Connie asked for Monday off. Two visits need cover.
    <div class="mt-2 pt-2 border-top d-flex gap-2">
      <button type="button" class="btn btn-primary btn-sm" data-bs-dismiss="toast">Approve</button>
      <button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="toast">Later</button>
    </div>
  </div>
</div>

Placement

Bootstrap's .toast-container with position utilities and its own toast script. Pick a spot on the little screen and the toast appears there; the classes below follow your choice.

Bootstrap
Toast position

Classes in use

bottom-0 end-0

Show code
<div class="toast-container position-fixed bottom-0 end-0 p-3">
  <div id="live-toast" class="toast" role="status" aria-live="polite" aria-atomic="true">
    <div class="toast-header">
      <strong class="me-auto">Basalt</strong>
      <small>just now</small>
      <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
    </div>
    <div class="toast-body">Service windows saved.</div>
  </div>
</div>

<script>
  bootstrap.Toast.getOrCreateInstance(document.getElementById('liveToast')).show();
</script>

Status toasts

Four tones on one quiet surface. The color lives in the icon tile and a thin edge, so a stack of mixed toasts still reads calmly.

Style

Saved

Service windows updated for the weekend.

Running low

Car 7 is down to 4 boxes of gloves.

Heads up

The roster starts at 7:00 am this Saturday.

Show code
<div class="toast basalt-notice basalt-notice-success show" role="status" aria-atomic="true">
  <span class="basalt-notice-mark" aria-hidden="true"><i class="bi bi-check2-circle"></i></span>
  <div class="basalt-notice-content">
    <p class="basalt-notice-head">Saved</p>
    <p class="basalt-notice-msg">Service windows updated for the weekend.</p>
  </div>
</div>
<!-- Tones: --primary, --success, --warning, --danger, --info -->

Snackbar

A single dark line with one action, for quick confirmations at the foot of the screen. It flips to light in dark mode, so it always stands off the page.

Style

Order #1058 marked as collected

Back online. 3 orders synced.

Show code
<div class="toast basalt-notice basalt-notice-bar show" role="status" aria-atomic="true">
  <p class="basalt-notice-msg">Order #1058 marked as collected</p>
  <button type="button" class="basalt-notice-anchor">Undo</button>
</div>

Toast with details

Enough detail to act without opening anything: what came in, how much, and when it is due, with the two likely next steps.

Content

New order #1063 2 min ago

  • Bar Loafers2 × $790.00
  • Leather Trench Coat1 × $3,200.00
  • Ships today by 4:30 pm$267.00
Show code
<div class="toast basalt-notice basalt-notice-primary show" role="status" aria-atomic="true">
  <span class="basalt-notice-mark" aria-hidden="true"><i class="bi bi-bag-check"></i></span>
  <div class="basalt-notice-content">
    <p class="basalt-notice-head">New order #1063 <span class="basalt-notice-when">2 min ago</span></p>
    <ul class="basalt-notice-copy">
      <li><span>Shield Sunglasses</span><span>2 &times; $520.00</span></li>
      <li class="basalt-notice-sum"><span>Ships today by 4:30 pm</span><span>$78.00</span></li>
    </ul>
    <div class="basalt-notice-acts">
      <button type="button" class="btn btn-sm basalt-notice-action">Start packing</button>
      <button type="button" class="btn btn-sm basalt-notice-action basalt-notice-action-quiet">View order</button>
    </div>
  </div>
  <button type="button" class="basalt-notice-dismiss" aria-label="Dismiss">
    <i class="bi bi-x-lg" aria-hidden="true"></i></button>
</div>

Toast with quick reply

A message toast with a reply field, so a short answer never needs a page change. Sending swaps the field for a confirmation.

Content

Carly McCall now

Could you add three seats before our new carers start on Monday?

Show code
<div class="toast basalt-notice basalt-notice-chat show" role="status" aria-atomic="true">
  <span class="basalt-notice-face" aria-hidden="true">IM</span>
  <div class="basalt-notice-content">
    <p class="basalt-notice-head">Carly McCall <span class="basalt-notice-when">now</span></p>
    <p class="basalt-notice-msg">Could you add three seats before Monday?</p>
    <form class="basalt-notice-answer">
      <label class="visually-hidden" for="reply">Reply to Carly McCall</label>
      <input type="text" class="form-control form-control-sm" id="reply" placeholder="Reply to Carly">
      <button type="submit" class="btn btn-sm basalt-notice-action">Send</button>
    </form>
  </div>
  <button type="button" class="basalt-notice-dismiss" aria-label="Dismiss message">
    <i class="bi bi-x-lg" aria-hidden="true"></i></button>
</div>

Undo toast

Remove happens at once and the toast offers the way back. Undo puts the row where it was and returns focus to it; if the time runs out, the removal sticks.

Interactive
  • Draped Column GownClothing, ML-GOWN $2,150.00
  • Leather Trench CoatClothing, ML-TRCH $3,200.00
  • Bar LoafersClothing, ML-LOAF $790.00
  • E-Gift Card, $250Extras, ML-GIFT250 $25.00
Show code
<script>
  row.hidden = true;                          // remove at once
  const t = basaltToasts.push({
    icon: 'bi-trash3',
    title: 'Removed Draped Column Gown',
    text: 'It is off the shop list.',
    duration: 6000,
    actions: [{ label: 'Undo', onClick: () => { row.hidden = false; button.focus(); } }],
    onTimeout: () => row.remove()             // time ran out: make it stick
  });
</script>

Loading toast

One toast that follows a job from start to finish. It spins while the work runs, then turns into the result in place. A failure stays until it is read and offers to try again.

Interactive
price-list-october.csv48 products, 12 new prices
Show code
<script>
  const t = basaltToasts.push({ tone: 'loading', title: 'Publishing price list', duration: 0 });
  publish()
    .then(() => t.update({ tone: 'success', icon: 'bi-check2-circle',
                           title: 'Price list published', duration: 5000 }))
    .catch(() => t.update({ tone: 'danger', icon: 'bi-wifi-off',
                            title: 'Could not reach Fieldline', duration: 0,
                            actions: [{ label: 'Try again', onClick: retry }] }));
</script>

Toast stack with progress and undo

One stack for the whole app. New toasts land in front and older ones fold behind them; point at the stack or tab into it and it fans out. Each toast shows the time it has left, and every timer waits while you are reading.

Interactive

Send

Where the stack sits

Alt + T jumps to the toasts. Esc closes the one in focus.

Show code
<!-- The stack is built on first use; there is no markup to add. -->
<script>
  const t = basaltToasts.push({
    tone: 'success',                 // primary, success, warning, danger, info
    icon: 'bi-cash-coin',
    title: 'Payment received',
    text: '$267.00 for order #1063.',
    duration: 6000,                  // 0 keeps it until closed
    actions: [{ label: 'Undo', onClick: () => restore() }]
  });

  t.update({ title: 'Refunded', tone: 'info' });
  t.dismiss();

  basaltToasts.position('top-end');  // bottom-end, bottom-center, top-end, top-center
  basaltToasts.clear();
</script>
Basalt just now
Service windows saved. This toast sits at bottom right.