Skip to content
Priority Selector preview
Rendered from the SwiftUI source on this page.

Priority Selector

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

A colored Low / Medium / High priority picker.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

PrioritySelectorCard.swift
// Priority Selector · syxUI · https://syxui.dev/components/sel-priority
// 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)
    }
}

// Priority selector (colored)
struct PrioritySelectorCard: View {
    @State private var sel = 1
    let opts: [(String, Color)] = [("Low", Color(red: 0.16, green: 0.66, blue: 0.40)),
                                            ("Medium", Color(red: 0.98, green: 0.62, blue: 0.11)),
                                            ("High", Color(red: 0.90, green: 0.24, blue: 0.28))]
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("Priority").font(.system(size: 15, weight: .semibold))
            HStack(spacing: 10) {
                ForEach(Array(opts.enumerated()), id: \.offset) { i, o in
                    let on = sel == i
                    HStack(spacing: 6) {
                        Circle().fill(o.1).frame(width: 8, height: 8)
                        Text(o.0).font(.system(size: 14, weight: .medium)).foregroundStyle(on ? o.1 : .primary)
                    }
                    .frame(maxWidth: .infinity).padding(.vertical, 11)
                    .background(on ? o.1.opacity(0.12) : Color.primary.opacity(0.04), in: RoundedRectangle(cornerRadius: 10, style: .continuous))
                    .overlay(RoundedRectangle(cornerRadius: 10, style: .continuous).stroke(on ? o.1.opacity(0.5) : .clear, lineWidth: 1))
                    .onTapGesture { sel = i }
                }
            }
        }.formaCard().frame(width: 330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17