Skip to content
Add to Cart preview
Rendered from the SwiftUI source on this page.

Add to Cart

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

An add-to-cart button with an inline price.

Buttons · SwiftUI · iOS 17

  • buttons
  • swiftui

The actual source

CartButtonCard.swift
// Add to Cart · syxUI · https://syxui.dev/components/btn-cart
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Add to cart with price
struct CartButtonCard: View {
    var body: some View {
        HStack {
            Image(systemName: "cart.fill").font(.system(size: 15))
            Text("Add to Cart").font(.system(size: 16, weight: .semibold))
            Spacer()
            Text("$129").font(.system(size: 16, weight: .bold))
        }.foregroundStyle(.white).padding(.horizontal, 20).padding(.vertical, 15).background(Color.primary, in: RoundedRectangle(cornerRadius: 14, style: .continuous)).frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17