Skip to content
Bottom Sheet preview
Rendered from the SwiftUI source on this page.

Bottom Sheet

From syxUI — written for both platforms, not translated between them.

A bottom sheet with a grabber and primary action.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

BottomSheet.swift
// Bottom Sheet · syxUI · https://syxui.dev/components/sheet-bottom
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let shBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
let shRed = Color(red: 0.90, green: 0.24, blue: 0.28)

func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
    c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}

// Bottom sheet with grabber + CTA
struct BottomSheet: View {
    var body: some View {
        shCard(330, radius: 22) {
            VStack(spacing: 14) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5)
                Text("Delete Account").font(.system(size: 19, weight: .bold))
                Text("Do you wish to permanently delete your account? This can take up to 30 days.").font(.system(size: 14)).foregroundStyle(.secondary).multilineTextAlignment(.center)
                Text("Delete Account").font(.system(size: 16, weight: .semibold)).foregroundStyle(.white).frame(maxWidth: .infinity).padding(.vertical, 14).background(shRed, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
                Text("Cancel").font(.system(size: 16, weight: .semibold)).foregroundStyle(shBlue)
            }.padding(.horizontal, 20).padding(.top, 12).padding(.bottom, 18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17