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

Half Sheet

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

A half-height detail sheet.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

HalfSheet.swift
// Half Sheet · syxUI · https://syxui.dev/components/sheet-half
// 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)

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)
}

// Half-height detail sheet
struct HalfSheet: View {
    var body: some View {
        shCard(330, radius: 22) {
            VStack(alignment: .leading, spacing: 12) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5).frame(maxWidth: .infinity)
                HStack(spacing: 12) { RoundedRectangle(cornerRadius: 10).fill(shBlue.opacity(0.15)).frame(width: 50, height: 50).overlay(Image(systemName: "cup.and.saucer.fill").foregroundStyle(shBlue)); VStack(alignment: .leading, spacing: 2) { Text("Blue Bottle Coffee").font(.system(size: 16, weight: .semibold)); Text("0.3 mi · Open until 8 PM").font(.system(size: 13)).foregroundStyle(.secondary) }; Spacer() }
                HStack(spacing: 10) { Label("Directions", systemImage: "arrow.triangle.turn.up.right.diamond.fill").font(.system(size: 14, weight: .semibold)).foregroundStyle(.white).frame(maxWidth: .infinity).padding(.vertical, 11).background(shBlue, in: Capsule()); Image(systemName: "phone.fill").foregroundStyle(shBlue).frame(width: 44, height: 44).background(shBlue.opacity(0.12), in: Circle()) }
            }.padding(18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17