https://github.com/nvmnovem/swift-web-ui
[SwiftWebUI] - Build websites with Swift using a SwiftUI-inspired declarative API
https://github.com/nvmnovem/swift-web-ui
framework
Last synced: 4 days ago
JSON representation
[SwiftWebUI] - Build websites with Swift using a SwiftUI-inspired declarative API
- Host: GitHub
- URL: https://github.com/nvmnovem/swift-web-ui
- Owner: NVMNovem
- Created: 2026-06-25T20:49:22.000Z (5 days ago)
- Default Branch: main
- Last Pushed: 2026-06-25T21:25:17.000Z (5 days ago)
- Last Synced: 2026-06-25T23:10:50.372Z (5 days ago)
- Topics: framework
- Language: Swift
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# SwiftWebUI
SwiftWebUI is a SwiftUI-like view DSL for rendering browser UI to HTML and CSS resources. SwiftHTML owns HTML rendering, SwiftCSS owns CSS rendering, and SwiftWebUI keeps the component and modifier APIs at the web UI layer.
## Example
```swift
import SwiftWebUI
enum PortfolioTab: String, CaseIterable {
case info
case personal
case contact
}
struct PortfolioPreview: View {
var body: some View {
VStack(alignment: .leading, spacing: 24) {
Text("Maak websites met Swift.")
.font(.heroTitle)
.foregroundStyle(.primary)
TabBar(selection: PortfolioTab.info) {
Tab("Info", value: PortfolioTab.info)
Tab("Persoonlijk", value: PortfolioTab.personal)
Tab("Contact", value: PortfolioTab.contact)
}
Link("Neem contact op", destination: "#contact")
.buttonStyle(.primary)
}
.padding(24)
}
}
let rendered = HTMLRenderer().renderView(PortfolioPreview())
let document = WebDocument(
title: "Portfolio",
renderedView: rendered,
stylesheetPath: "styles.css"
)
let html = document.htmlString(prettyPrinted: false)
let css = rendered.cssString(prettyPrinted: false)
```
`TabBar` is static-first today. `TabBar(selection:)` renders the selected tab with accessible tab semantics and generated SwiftCSS resources. A `Binding` initializer exists for render compatibility, but client-side tab switching is planned for the future client-state runtime.