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

Consent Sheet

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

A privacy / cookie consent sheet.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

ConsentSheet.swift
// Consent Sheet · syxUI · https://syxui.dev/components/sheet-consent
// 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)
}

// Consent / cookie sheet
struct ConsentSheet: View {
    var body: some View {
        shCard(330, radius: 22) {
            VStack(spacing: 12) {
                Image(systemName: "hand.raised.fill").font(.system(size: 24)).foregroundStyle(shBlue)
                Text("We value your privacy").font(.system(size: 17, weight: .bold))
                Text("We use cookies to enhance your experience and analyze traffic.").font(.system(size: 13)).foregroundStyle(.secondary).multilineTextAlignment(.center)
                HStack(spacing: 10) { Text("Manage").font(.system(size: 15, weight: .semibold)).foregroundStyle(shBlue).frame(maxWidth: .infinity).padding(.vertical, 12).overlay(RoundedRectangle(cornerRadius: 12).stroke(shBlue.opacity(0.4))); Text("Accept All").font(.system(size: 15, weight: .semibold)).foregroundStyle(.white).frame(maxWidth: .infinity).padding(.vertical, 12).background(shBlue, in: RoundedRectangle(cornerRadius: 12, style: .continuous)) }
            }.padding(18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17