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

Booking Picker

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

A date-strip + slot booking picker.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

PickerBooking.swift
// Booking Picker · syxUI · https://syxui.dev/components/picker-booking
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let pkBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

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)
    }
}

struct PickerBooking: View { var body: some View { VStack(alignment: .leading, spacing: 12) { HStack(spacing: 8) { ForEach(Array([("Mon", "22"), ("Tue", "23"), ("Wed", "24"), ("Thu", "25")].enumerated()), id: \.offset) { i, d in VStack(spacing: 4) { Text(d.0).font(.system(size: 11)).foregroundStyle(i == 1 ? .white : .secondary); Text(d.1).font(.system(size: 15, weight: .semibold)).foregroundStyle(i == 1 ? .white : .primary) }.frame(maxWidth: .infinity).padding(.vertical, 10).background(i == 1 ? pkBlue : Color.primary.opacity(0.05), in: RoundedRectangle(cornerRadius: 12)) } }; HStack(spacing: 8) { ForEach(Array(["10:00", "11:30", "2:00"].enumerated()), id: \.offset) { i, t in Text(t).font(.system(size: 13, weight: .medium)).foregroundStyle(i == 0 ? pkBlue : .primary).frame(maxWidth: .infinity).padding(.vertical, 9).overlay(RoundedRectangle(cornerRadius: 9).stroke(i == 0 ? pkBlue : Color.primary.opacity(0.12), lineWidth: i == 0 ? 1.5 : 1)) } } }.formaCard().frame(width: 300) } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17