Components
Alerts
The style's banners, toasts, an inline error and a confirmation dialog. Built in all 5 Effect UI styles, in light and dark mode.










Source: Ledger
AlertsView.swift in the free Ledger style. It needs Ledger's Theme.swift, which comes with the style: join early access on the home page and it's emailed to you.
import SwiftUI
struct AlertsView: View {
@State private var showsToast = true
@State private var showsBanner = true
@State private var limit = "0.00"
@State private var confirmed: Bool? = nil
@FocusState private var editingLimit: Bool
private var limitValue: Double {
Double(limit.replacingOccurrences(of: ",", with: "")) ?? 0
}
private var limitInvalid: Bool { limitValue <= 0 }
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: Theme.Space.xxl) {
ScreenHeader(eyebrow: "Components", title: "Feedback")
toastSection
bannerSection
formErrorSection
warningSection
confirmSection
}
.padding(.horizontal, Theme.Space.margin)
.padding(.top, Theme.Space.sm)
.padding(.bottom, Theme.Space.xxl)
}
.scrollIndicators(.hidden)
.scrollDismissesKeyboard(.interactively)
.paperBackground()
}
// MARK: 01 Toast
private var toastSection: some View {
Specimen(number: 1, title: "Success toast", replay: showsToast ? nil : { show { showsToast = true } }) {
if showsToast {
HStack(spacing: Theme.Space.md) {
Image(systemName: "checkmark")
.font(.system(size: 13, weight: .semibold))
VStack(alignment: .leading, spacing: Theme.Space.xxs) {
Text("Exported 248 transactions")
.ledgerType(.bodyMd)
.fontWeight(.semibold)
Text("tilde-november-2026.csv")
.font(.system(size: 13, weight: .regular, design: .monospaced))
.opacity(0.7)
}
Spacer(minLength: Theme.Space.sm)
Button("Undo") { hide { showsToast = false } }
.buttonStyle(TextButtonStyle(color: Theme.surface))
}
.foregroundStyle(Theme.surface)
.padding(.horizontal, Theme.Space.lg)
.padding(.vertical, Theme.Space.md)
.background(RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous).fill(Theme.ruleStrong))
.transition(.opacity.combined(with: .move(edge: .bottom)))
.accessibilityElement(children: .combine)
}
}
}
// MARK: 02 Banner
private var bannerSection: some View {
Specimen(number: 2, title: "Informational banner", replay: showsBanner ? nil : { show { showsBanner = true } }) {
if showsBanner {
HStack(alignment: .top, spacing: Theme.Space.md) {
Image(systemName: "info.circle")
.font(.system(size: 15, weight: .regular))
.foregroundStyle(Theme.onSurfaceVariant)
.padding(.top, 1)
VStack(alignment: .leading, spacing: Theme.Space.xxs) {
Text("Chase syncs overnight")
.ledgerType(.bodyMd)
.fontWeight(.semibold)
.foregroundStyle(Theme.onSurface)
Text("New transactions appear by 6:00 AM. Balances refresh every hour.")
.ledgerType(.bodySm)
.foregroundStyle(Theme.onSurfaceVariant)
.fixedSize(horizontal: false, vertical: true)
}
Spacer(minLength: 0)
Button {
hide { showsBanner = false }
} label: {
Image(systemName: "xmark")
.font(.system(size: 11, weight: .semibold))
.foregroundStyle(Theme.onSurfaceMuted)
.frame(width: 28, height: 28)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.padding(.top, -6)
.padding(.trailing, -6)
.accessibilityLabel("Dismiss")
}
.padding(Theme.Space.md)
.background(RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous).fill(Theme.surfaceRaised))
.overlay(RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous).strokeBorder(Theme.rule, lineWidth: 0.5))
.transition(.opacity)
}
}
}
// MARK: 03 Inline error
private var formErrorSection: some View {
Specimen(number: 3, title: "Inline form error") {
VStack(alignment: .leading, spacing: Theme.Space.sm) {
MicroLabel("Monthly limit · Dining out", color: limitInvalid ? Theme.negative : Theme.onSurfaceMuted)
HStack(spacing: Theme.Space.xs) {
Text("$")
.ledgerType(.numeralMd)
.foregroundStyle(Theme.onSurfaceMuted)
TextField("250.00", text: $limit)
.ledgerType(.numeralMd)
.foregroundStyle(Theme.onSurface)
.keyboardType(.decimalPad)
.focused($editingLimit)
}
.ledgerField(focused: editingLimit, invalid: limitInvalid)
if limitInvalid {
HStack(alignment: .top, spacing: Theme.Space.xs) {
Image(systemName: "exclamationmark.circle")
.font(.system(size: 13, weight: .semibold))
.padding(.top, 1)
Text("Enter a limit above $0.00. Last month you spent $286.45 here.")
.ledgerType(.bodySm)
.monospacedDigit()
.fixedSize(horizontal: false, vertical: true)
}
.foregroundStyle(Theme.negative)
.transition(.opacity)
} else {
Text("Tilde alerts you at 80% of this amount.")
.ledgerType(.bodySm)
.foregroundStyle(Theme.onSurfaceMuted)
.transition(.opacity)
}
}
.animation(Theme.Motion.stateChange, value: limitInvalid)
}
}
// MARK: 04 Warning
private var warningSection: some View {
Specimen(number: 4, title: "Warning callout") {
HStack(alignment: .top, spacing: Theme.Space.md) {
Rectangle()
.fill(Theme.ruleStrong)
.frame(width: 2)
VStack(alignment: .leading, spacing: Theme.Space.sm) {
HStack(spacing: Theme.Space.sm) {
Image(systemName: "exclamationmark.triangle")
.font(.system(size: 13, weight: .semibold))
Text("Dining out is over budget")
.ledgerType(.bodyMd)
.fontWeight(.semibold)
}
.foregroundStyle(Theme.onSurface)
Text("You have spent $286.45 of $250.00 with 3 days left in November.")
.ledgerType(.bodySm)
.monospacedDigit()
.foregroundStyle(Theme.onSurfaceVariant)
.fixedSize(horizontal: false, vertical: true)
HStack(alignment: .firstTextBaseline) {
Text(Money.signed(-36.45))
.ledgerType(.numeralMd)
.foregroundStyle(Theme.negative)
Text("over")
.ledgerType(.bodySm)
.foregroundStyle(Theme.onSurfaceMuted)
Spacer()
Button("Adjust budget") {}
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.primaryInk)
}
}
.padding(.vertical, Theme.Space.xxs)
}
.fixedSize(horizontal: false, vertical: true)
}
}
// MARK: 05 Confirmation
private var confirmSection: some View {
Specimen(number: 5, title: "Destructive confirmation", replay: confirmed == nil ? nil : { show { confirmed = nil } }) {
if let confirmed {
Text(confirmed ? "Chase Checking removed. 1,284 transactions deleted." : "Kept Chase Checking. Nothing changed.")
.ledgerType(.bodySm)
.monospacedDigit()
.foregroundStyle(Theme.onSurfaceVariant)
.frame(minHeight: Theme.Space.rowHeight, alignment: .leading)
.transition(.opacity)
} else {
VStack(alignment: .leading, spacing: Theme.Space.md) {
MonogramTile(letters: "CH", size: 40)
Text("Remove Chase Checking?")
.ledgerType(.headlineMd)
.foregroundStyle(Theme.onSurface)
Text("Tilde will stop syncing this account and delete its 1,284 transactions. Your bank account itself is not affected.")
.ledgerType(.bodyMd)
.monospacedDigit()
.foregroundStyle(Theme.onSurfaceVariant)
.fixedSize(horizontal: false, vertical: true)
HStack(spacing: Theme.Space.sm) {
Button("Cancel") { show { self.confirmed = false } }
.buttonStyle(.ledgerSecondary)
Button("Delete") { show { self.confirmed = true } }
.buttonStyle(DestructiveButtonStyle())
}
.padding(.top, Theme.Space.sm)
}
.ledgerCard()
.transition(.opacity)
}
}
.sensoryFeedback(.warning, trigger: confirmed)
}
// MARK: Motion
private func show(_ change: () -> Void) {
withAnimation(Theme.Motion.surfaceEnter, change)
}
private func hide(_ change: () -> Void) {
withAnimation(Theme.Motion.surfaceExit, change)
}
}
// MARK: - Helpers
/// Numbered caption above a component, with an optional "Show again" for dismissed specimens.
private struct Specimen<Content: View>: View {
let number: Int
let title: String
var replay: (() -> Void)? = nil
@ViewBuilder var content: Content
var body: some View {
VStack(alignment: .leading, spacing: Theme.Space.md) {
HStack(alignment: .firstTextBaseline) {
MicroLabel(String(format: "%02d · %@", number, title))
Spacer()
if let replay {
Button("Show again", action: replay)
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.onSurfaceVariant)
.transition(.opacity)
}
}
.frame(minHeight: 20)
content
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}
/// Paper button with negative text and a negative rule. Negative never fills a background.
private struct DestructiveButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.ledgerType(.headlineMd)
.foregroundStyle(Theme.negative)
.frame(maxWidth: .infinity)
.frame(height: 52)
.background(RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous).fill(Theme.surface))
.overlay(RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous).strokeBorder(Theme.negative, lineWidth: 1))
.opacity(configuration.isPressed ? 0.6 : 1)
.animation(Theme.Motion.stateChange, value: configuration.isPressed)
}
}
#Preview("Light") {
AlertsView()
}
#Preview("Dark") {
AlertsView().preferredColorScheme(.dark)
}
More screens





