Skip to content
Availability Grid preview
Rendered from the SwiftUI source on this page.

Availability Grid

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

A weekly availability grid.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

PickerAvailability.swift
// Availability Grid · syxUI · https://syxui.dev/components/picker-availability
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let pkGreen = Color(red: 0.16, green: 0.66, blue: 0.40)

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 PickerAvailability: View { var body: some View { VStack(alignment: .leading, spacing: 10) { Text("Weekly availability").font(.system(size: 14, weight: .semibold)); ForEach(Array([("Mon", [true, true, false]), ("Tue", [true, false, true]), ("Wed", [false, true, true])].enumerated()), id: \.offset) { _, row in HStack(spacing: 8) { Text(row.0).font(.system(size: 13)).foregroundStyle(.secondary).frame(width: 36, alignment: .leading); ForEach(Array(["AM", "PM", "Eve"].enumerated()), id: \.offset) { i, label in Text(label).font(.system(size: 12, weight: .medium)).foregroundStyle(row.1[i] ? pkGreen : .secondary.opacity(0.5)).frame(maxWidth: .infinity).padding(.vertical, 7).background((row.1[i] ? pkGreen.opacity(0.14) : Color.primary.opacity(0.04)), in: RoundedRectangle(cornerRadius: 8)) } } } }.formaCard().frame(width: 300) } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17