Skip to content
Reorderable Rows preview
Rendered from the SwiftUI source on this page.

Reorderable Rows

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

Rows with drag handles for reordering.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

DragRow.swift
// Reorderable Rows · syxUI · https://syxui.dev/components/list-drag
// 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)
    }
}

// Reorderable drag row
struct DragRow: View {
    let rows = ["Monday", "Tuesday", "Wednesday"]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) { Image(systemName: "line.3.horizontal").font(.system(size: 14)).foregroundStyle(.secondary.opacity(0.5)); Text(r).font(.system(size: 15, weight: .medium)); Spacer(); Image(systemName: "eye").font(.system(size: 14)).foregroundStyle(.secondary) }.padding(.vertical, 11)
                if i < rows.count - 1 { Divider() }
            }
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17