Skip to content
Copy Button preview
Rendered from the SwiftUI source on this page.

Copy Button

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

A code field with a copy button.

Buttons · SwiftUI · iOS 17

  • buttons
  • swiftui

The actual source

CopyButtonCard.swift
// Copy Button · syxUI · https://syxui.dev/components/btn-copy
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let btnBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

// Copy code button
struct CopyButtonCard: View {
    var body: some View {
        HStack(spacing: 0) {
            Text("FORMA25").font(.system(size: 15, weight: .medium, design: .monospaced)).padding(.leading, 14)
            Spacer()
            HStack(spacing: 5) { Image(systemName: "doc.on.doc"); Text("Copy") }.font(.system(size: 14, weight: .semibold)).foregroundStyle(.white).padding(.horizontal, 16).padding(.vertical, 12).background(btnBlue)
        }.overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(Color.primary.opacity(0.12), lineWidth: 1)).clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous)).frame(width: 280)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17