Introducing WebUI: Declarative WKWebView for SwiftUI (original) (raw)

Hi Swift Community!

I'm excited to introduce WebUI - a powerful library for declaratively using WKWebView in SwiftUI.
WebUI is designed to align with existing SwiftUI interfaces such as ScrollView and ScrollViewReader. Therefore, its interfaces are intuitive for developers familiar with SwiftUI.

Key Features

Quick Example

Here's a quick example:

struct ContentView: View {
    var body: some View {
        WebViewReader { proxy in
            VStack(spacing: 16) {
                Text(proxy.title ?? "")

                HStack {
                    Button {
                        proxy.goBack()
                    } label: {
                        Label("Go Back", systemImage: "arrow.backward")
                            .labelStyle(.iconOnly)
                    }
                    .disabled(!proxy.canGoBack)

                    Spacer()
                }
                .padding(.horizontal)

                WebView(request: URLRequest(url: URL(string: "https://forums.swift.org/")!))
                    .allowsBackForwardNavigationGestures(true)
                    .refreshable()
            }
        }
    }
}

Get Started

The library is currently available for use on iOS and macOS. To learn more, please check out the documentation and the GitHub repository.

I look forward to your feedback and contributions!