Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Instantly Preview HTML Using a SwiftUI Web View

Instantly Preview HTML Using a SwiftUI Web View

Daily Coding Tip 045

Type Safely's avatar
Type Safely
Feb 08, 2021
∙ Paid

Share this post

Type Safely
Type Safely
Instantly Preview HTML Using a SwiftUI Web View
Share
Image by Pexels from Pixabay

There still isn’t a web view in SwiftUI, but we can make a live HTML preview using WebKit.

This requires us to combine a WKWebView and a Binding to the HTML string we want to preview. When the HTML string changes, we simply load it into the web view, refreshing the content that will be displayed.

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share