Tabs

main

Tabs in SwiftUI
heestand-xyz/Tabs

Tabs

Tabs built in SwiftUI for iOS and macOS.

Move and close tabs in UI. Open tabs via binding. Style via content callback.

Swift Package

.package(url: "https://github.com/heestand-xyz/Tabs", from: "1.0.0")

Setup

var body: some View {
   
    Tabs(openIDs: $openIDs,
         activeID: $activeID) { value in
        
        if let thing = things.first(where: { $0.id == value.id }) {
        
            ZStack {
                
                if isActive {
                    Color.accentColor.opacity(0.75)
                } else {
                    Color.primary.opacity(0.1)
                }
                
                Label {
                    Text(thing.name)
                } icon: {
                    Image(systemName: "circle")
                }
                .padding(.horizontal, value.height)
            }
            .help(thing.name)
        }
    }
}

Constructor

public init(
    openIDs: Binding<[UUID]>,
    activeID: Binding<UUID?>,
    spacing: CGFloat = .tabSpacing,
    width: CGFloat? = nil,
    height: CGFloat = CGSize.tabSize.height,
    @ViewBuilder content: @escaping (Tabs.Value) -> Content
) { ... }

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Nov 29 2022 03:50:20 GMT-0500 (GMT-05:00)