Issue #841

Declare generic on RawRepresentable

import SwiftUI

struct TabStrip<T: RawRepresentable & Hashable>: View where T.RawValue == String {
    let values: [T]
    @Binding var selected: T

    var body: some View {
        ScrollView(.horizontal, showsIndicators: false) {
            LazyHStack(spacing: 24) {
                ForEach(values, id: \.self) { value in
                    Button(action: {
                        selected = value
                    }) {
                        Text(value.rawValue)
                            .foregroundColor(selected == value ? Asset.textPrimary.color : Asset.textSecondary.color)
                            .fontWeight(selected == value ? .semibold : .regular)
                            .padding(6)
                    }
                    .buttonStyle(PlainButtonStyle())
                }
            }
        }
        .frame(height: 26)
    }
}

struct DemoView: View {
    enum Element: String, CaseIterable {
        case fire
        case water
        case metal
        case soil
        case wood
    }

    @State var selected: Element = .fire

    var body: some View {
        TabStrip(
            values: Element.allCases,
            selected: $selected
        )
    }
}