概要
Easily show RichText(html) in SwiftUI
Web・アプリ開発できること
- Cross-platform — iOS 15.0+ and macOS 12.0+, Swift 5.9+
- Automatic sizing — the view resizes itself as the content lays out, including late images, web fonts and <details> toggles
- Theming — automatic light/dark mode, custom color sets, transparent or custom backgrounds
- Typography — system, monospaced, italic, custom and bundled fonts, with Dynamic Type support
計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルRichText
Render HTML in SwiftUI.
RichText sizes itself to its content, so HTML fits into a layout like any other view.
Styling, light and dark theming, custom fonts, media callbacks and typed errors are built in.

|
|
|
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------: |:------------------------------------------------------------------------------------------------------------------------------: |
| Light Mode | Dark Mode |
✨ Features
- Cross-platform — iOS 15.0+ and macOS 12.0+, Swift 5.9+
- Automatic sizing — the view resizes itself as the content lays out, including late images, web fonts and
<details>toggles - Theming — automatic light/dark mode, custom color sets, transparent or custom backgrounds
- Typography — system, monospaced, italic, custom and bundled fonts, with Dynamic Type support
- Interactive media — click callbacks for images and videos
- Link handling — Safari,
SFSafariViewController, or your own handler - HTML5 —
<figure>,<details>,<summary>,<figcaption>and the semantic elements - Error reporting — typed errors for load, configuration and CSS failures
tvOS and watchOS are not supported: Apple does not ship
WKWebViewon those platforms.
🚀 Quick Start
import SwiftUI
import RichText
struct ContentView: View {
let html = """
<h1>Welcome to RichText</h1>
<p>A powerful HTML renderer for SwiftUI.</p>
"""
var body: some View {
ScrollView {
RichText(html: html)
.colorScheme(.auto)
.lineHeight(170)
.imageRadius(12)
.placeholder { ProgressView() }
.onMediaClick { media in
if case .image(let src) = media { print(src) }
}
.onError { error in print(error) }
}
}
}
See the API reference for every modifier, and advanced usage for custom fonts, themes and complete examples.
📦 Installation
Swift Package Manager (Recommended)
- In Xcode, select File → Add Package Dependencies...
- Enter the repository URL:
https://github.com/NuPlay/RichText.git - Select version rule: "Up to Next Major Version" from "3.1.1"
- Click Add Package
Manual Package.swift
Add RichText to your Package.swift:
dependencies: [
.package(url: "https://github.com/NuPlay/RichText.git", .upToNextMajor(from: "3.1.1"))
],
targets: [
.target(
name: "YourTarget",
dependencies: ["RichText"]
)
]
📖 Documentation
| Document | Contents |
|---|---|
| API Reference | Every initializer, modifier and utility |
| Advanced Usage | Custom fonts, theming, media handling, performance, full examples |
| Troubleshooting | Common issues and platform-specific notes |
| Migration Guide | Upgrading from v2.x |
| Changelog | Release notes |
| Contributing | How to report issues and send patches |
🌟 Used By
Open-source apps that render their content with RichText:
| Project | What it is |
|---|---|
| IBM/mac-ibm-notifications | macOS agent for displaying notifications and alerts to managed devices |
| AudioBooth | iOS companion app for Audiobookshelf |
Each of these declares RichText in its public dependency manifest. No affiliation or endorsement is implied in either direction. Using RichText in your project? Open a PR to add it.
📄 License
RichText is available under the MIT license. See the LICENSE file for more info.
🙏 Acknowledgments
- Built with WebKit for reliable HTML rendering
- Inspired by the SwiftUI community's need for rich text solutions
- Thanks to all contributors and users
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with ❤️ for the SwiftUI community
関連プロジェクトを探す
読み込み中…