Docs
Sheets

Toast

A single liquid glass toast with a tile tinted for its kind, a countdown ring that pauses on touch and an optional Undo.

$npx swiftpieces add Toast
Try it in the Playground Use it on a real screen, take it apart, remix it, and copy the SwiftUI. No account needed.
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasstoastnotificationundofeedbackhaptic
Type
Toast
Files
Toast.swift
Depends on
Nothing (Apple frameworks only)
Version
2.3.0
In a full screen · SwiftPieces ProNotificationsAn activity feed where new alerts land as a stack of toasts you can fan out and swipe away.

Presents one transient toast on the top or bottom edge.

Notes

  • Single instance by design. Presenting again while visible does nothing. Every touch, release, action and new toast starts a fresh run of the countdown, and only the latest run can dismiss, so a timer left over from an earlier toast never closes a newer one.
  • The toast is liquid glass, in three parts that rest joined: a glass card with the message and the detail, a round tile bubble at its leading end, and the action bubble at its trailing end, each held to the card by a liquid neck. The tile is tinted for its kind: .success sage, .warning and .error butter, and .info clear glass. All text is semibold.
  • It arrives calmly from its edge, landing with a slight give, with the message already in place, so it can be read at once. As it settles the tile buds out of the card's leading end and then the action out of its trailing end, each pulling a neck as it springs to its place, with the kind's haptic (success, warning, error, or a soft tap for info). Both bubbles keep their place in the layout while they are inside the card, so the card never resizes. It leaves faster and firmer than it came, all in one piece, and slides all the way out past its edge. The presentation animation is scoped to the toast, so changes the host makes in the same transaction keep their own animation.
  • detail adds a quieter second line. The action is a signal bubble: tapping it swaps the title for a check, pops the bubble with a light haptic, runs the handler, then dismisses a beat later. It still dismisses if the handler takes the view away first (switching tabs, pushing a screen), so the action never comes back live.
  • The countdown is a .task on the toast and is cancelled the moment the toast leaves. Touching the toast pauses it: the thin bar freezes and the toast sinks toward your finger. Releasing resumes from where it stopped, and so does a touch the system interrupts, such as an incoming call.
  • Swipe toward the edge to dismiss. The toast stays under your finger that way and gives with rubber-band resistance the other way. A swipe that would carry past 40 points leaves at the toast's own speed; anything shorter springs back at the speed you let go, with a little give past its resting place. Grabbing it again while it springs back takes it over from where it is, without a jump.
  • On iOS 26 the parts are Liquid Glass and the necks between them are real; before that they are frosted glass with a light rim. With Reduce Transparency they are solid, so the toast reads the same over any content.
  • With Reduce Motion the toast fades in and out, the bubbles fade in where they rest instead of budding, the press dims instead of sinking, and the action's pop is off. Haptics, the tile's tint and the check still say what happened.
  • Placement reads the safe area of the view it is applied to: at the top it clears the Dynamic Island, at the bottom it rises with the keyboard. Apply the modifier to a view that does not ignore safe areas.
  • Colors live in Toast.Appearance (passed as appearance:), because Toast.Style already names the kind. surface and info default to .clear, which leaves them neutral glass; any other color tints that glass.
  • The message and detail are posted as a VoiceOver announcement on appear; the action button is a real button with its own label.
  • For stacked, queued alerts with a notifications feed, see the Notifications screen (toast stack) in SwiftPieces Pro.
  • v2.3: the countdown is a ring around the tile's glyph rather than a line under the card: it drains clockwise from the top on a faint track, holds while the toast is touched and once the action has run, and resumes with what is left. It is a clock, so it keeps running under Reduce Motion.

Usage

ToastExample()

Parameters

ParameterDescription
isPresentedShows the toast while true; the timer, swipe, and action set it back to false.
messageText to show. Keep it to one line.
detailOptional quieter second line, such as where the item went.
systemImageOptional SF Symbol; defaults to a symbol that matches style.
styleThe kind of toast, which picks the tile bubble's tint and default symbol: .info, .success, .warning, or .error.
durationSeconds before it dismisses on its own. The countdown pauses while the toast is touched.
position.top or .bottom edge to slide in from.
actionOptional trailing button (for example Undo), a signal glass bubble joined to the card. Tapping it swaps its title for a check, runs the handler, then dismisses a beat later.
appearanceColors and corner radius. Defaults to the SwiftPieces house palette, adapting to light and dark.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add Toast

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Toast" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All sheets →

Build it yourself: SwiftUI haptics guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

54 screens · 46 patterns · 48 flows · 12 templates · 31 Build Kit skills

Explore Pro