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

Like Button

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

A like button with a heart and count, both states.

Buttons · SwiftUI · iOS 17

  • buttons
  • swiftui

The actual source

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

import SwiftUI

// Like button (heart + count)
struct LikeButtonCard: View {
    var body: some View {
        HStack(spacing: 12) {
            HStack(spacing: 6) { Image(systemName: "heart.fill").foregroundStyle(.red); Text("248") }.font(.system(size: 15, weight: .medium)).padding(.horizontal, 16).padding(.vertical, 9).background(Color.red.opacity(0.1), in: Capsule())
            HStack(spacing: 6) { Image(systemName: "heart"); Text("247") }.font(.system(size: 15, weight: .medium)).foregroundStyle(.secondary).padding(.horizontal, 16).padding(.vertical, 9).overlay(Capsule().stroke(Color.primary.opacity(0.15), lineWidth: 1))
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17