Skip to content
Reaction Picker preview
Rendered from the SwiftUI source on this page.

Reaction Picker

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

A row of tappable reaction icons with one highlighted.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

ReactionPickerCard.swift
// Reaction Picker · syxUI · https://syxui.dev/components/sel-reaction
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

extension View {
    func formaCard(_ pad: CGFloat = 18) -> some View {
        self.padding(pad)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
            .shadow(color: .black.opacity(0.05), radius: 14, x: 0, y: 6)
    }
}

// Reaction picker (SF Symbols)
struct ReactionPickerCard: View {
    @State private var sel = 1
    let reactions: [(String, Color)] = [("hand.thumbsup.fill", Color(red: 0.0, green: 0.47, blue: 1.0)),
                                                 ("heart.fill", Color(red: 0.90, green: 0.24, blue: 0.28)),
                                                 ("star.fill", Color(red: 0.98, green: 0.62, blue: 0.11)),
                                                 ("flame.fill", Color(red: 0.98, green: 0.42, blue: 0.16)),
                                                 ("face.smiling", Color(red: 0.55, green: 0.40, blue: 0.90))]
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("How was it?").font(.system(size: 15, weight: .semibold))
            HStack(spacing: 10) {
                ForEach(Array(reactions.enumerated()), id: \.offset) { i, r in
                    let on = sel == i
                    Image(systemName: r.0).font(.system(size: 20)).foregroundStyle(on ? r.1 : .secondary)
                        .frame(maxWidth: .infinity).frame(height: 48)
                        .background(on ? r.1.opacity(0.14) : Color.primary.opacity(0.04), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
                        .scaleEffect(on ? 1.06 : 1)
                        .onTapGesture { sel = i }
                }
            }
        }.formaCard().frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17