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

Comment Sheet

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

A comments sheet with an input.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

CommentSheet.swift
// Comment Sheet · syxUI · https://syxui.dev/components/sheet-comment
// 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)
}

// Comment sheet
struct CommentSheet: View {
    var body: some View {
        shCard(330, radius: 22) {
            VStack(spacing: 14) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5)
                HStack { Text("Comments").font(.system(size: 17, weight: .semibold)); Text("24").font(.system(size: 14)).foregroundStyle(.secondary); Spacer() }
                HStack(spacing: 10) { Circle().fill(shBlue.opacity(0.2)).frame(width: 34, height: 34).overlay(Text("JW").font(.system(size: 12, weight: .semibold)).foregroundStyle(shBlue)); VStack(alignment: .leading, spacing: 2) { Text("James Wilson").font(.system(size: 13, weight: .semibold)); Text("This looks amazing!").font(.system(size: 14)) }; Spacer() }
                HStack(spacing: 10) { Text("Add a comment…").font(.system(size: 14)).foregroundStyle(.secondary); Spacer(); Image(systemName: "arrow.up.circle.fill").font(.system(size: 26)).foregroundStyle(shBlue) }.padding(.horizontal, 14).padding(.vertical, 8).overlay(Capsule().stroke(Color.primary.opacity(0.15)))
            }.padding(18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17