{"id":32150469,"url":"https://github.com/coenttb/swift-html","last_synced_at":"2026-02-21T10:32:08.784Z","repository":{"id":270340028,"uuid":"905738141","full_name":"coenttb/swift-html","owner":"coenttb","description":"The Swift HTML library built on swift-standards.","archived":false,"fork":false,"pushed_at":"2026-02-10T12:55:54.000Z","size":643,"stargazers_count":31,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-15T05:42:54.744Z","etag":null,"topics":["css","dark-mode","domain-specific-languages","dsl","html","result-builders","server-side-swift","swift","type-safe","web-development"],"latest_commit_sha":null,"homepage":"https://coenttb.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coenttb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["coenttb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2024-12-19T12:27:41.000Z","updated_at":"2026-02-10T12:55:58.000Z","dependencies_parsed_at":"2024-12-30T12:29:36.815Z","dependency_job_id":"5a2d7d0b-a7c7-4b6e-b81d-a29d5ae3dfdc","html_url":"https://github.com/coenttb/swift-html","commit_stats":null,"previous_names":["coenttb/swift-html"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/coenttb/swift-html","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coenttb","download_url":"https://codeload.github.com/coenttb/swift-html/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-html/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29679049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T09:33:50.764Z","status":"ssl_error","status_checked_at":"2026-02-21T09:33:19.949Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","dark-mode","domain-specific-languages","dsl","html","result-builders","server-side-swift","swift","type-safe","web-development"],"created_at":"2025-10-21T10:02:18.520Z","updated_at":"2026-02-21T10:32:08.778Z","avatar_url":"https://github.com/coenttb.png","language":"Swift","funding_links":["https://github.com/sponsors/coenttb"],"categories":["Related Packages"],"sub_categories":["Dependencies"],"readme":"# swift-html\n\n![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)\n\nThe Swift HTML library built on [swift-standards](https://github.com/swift-standards).\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage Examples](#usage-examples)\n- [Architecture](#architecture)\n- [Features](#features)\n- [Requirements](#requirements)\n- [License](#license)\n\n## Overview\n\nswift-html is a unified import for type-safe HTML generation. It re-exports [swift-html-rendering](https://github.com/coenttb/swift-html-rendering), [swift-css](https://github.com/coenttb/swift-css), [swift-svg](https://github.com/coenttb/swift-svg), and related packages—all grounded in [swift-standards](https://github.com/swift-standards) for domain-accurate representations of WHATWG and W3C specifications.\n\n## Installation\n\nAdd swift-html to your Package.swift:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-html\", from: \"0.1.0\")\n]\n```\n\nAdd to your target:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"HTML\", package: \"swift-html\"),\n    ]\n)\n```\n\n### Requirements\n\n- Swift 6.2+\n- macOS 26.0+, iOS 26.0+\n- Xcode 26.0+ (for Apple platforms)\n\n## Quick Start\n\n```swift\nimport HTML\n\nlet page = HTML.Document {\n    div {\n        h1 { \"Welcome\" }\n            .css\n            .color(.blue)\n            .fontSize(.px(24))\n\n        p { \"Type-safe HTML with CSS\" }\n            .css.color(light: .gray900, dark: .gray100)\n    }\n}\n\nlet html = try String(page)\n```\n\n## Usage Examples\n\n### Basic Elements\n\n```swift\ndiv { \"Content\" }\nh1 { \"Heading\" }\np { \"Paragraph\" }\na(href: \"/path\") { \"Link\" }\nbutton { \"Click me\" }\n```\n\n### CSS Styling (Fluent API)\n\n```swift\ndiv { \"Styled\" }\n    .css\n    .display(.flex)\n    .padding(.px(16))\n    .backgroundColor(.white)\n    .borderRadius(.px(8))\n```\n\n### Dark Mode\n\n```swift\n// Automatic light/dark variants\ndiv { \"Adaptive\" }\n    .css\n    .color(light: .gray900, dark: .gray100)\n    .backgroundColor(light: .white, dark: .hex(\"1a1a1a\"))\n\n// Theme colors (auto-adaptive)\ndiv { \"Themed\" }\n    .css.color(.blue)  // DarkModeColor with light/dark variants\n```\n\n### Layout Components\n\n```swift\nHStack(alignment: .top, spacing: .px(16)) {\n    div { \"Left\" }\n    Spacer()\n    div { \"Right\" }\n}\n\nVStack(alignment: .start, spacing: .px(12)) {\n    h2 { \"Title\" }\n    p { \"Content\" }\n}\n\nLazyVGrid(columns: [1, 2, 1]) {\n    div { \"A\" }\n    div { \"B\" }\n    div { \"C\" }\n}\n```\n\n### Custom Components\n\n```swift\nstruct Card: HTML.View {\n    let title: String\n    let content: String\n\n    var body: some HTML.View {\n        div {\n            h3 { title }\n            p { content }\n        }\n        .css\n        .padding(.px(24))\n        .backgroundColor(.white)\n        .borderRadius(.px(8))\n    }\n}\n\n// Usage\nCard(title: \"Hello\", content: \"World\")\n```\n\n### Media Queries\n\n```swift\ndiv { \"Responsive\" }\n    .css\n    .display(.block)\n    .media(.minWidth(.px(768))) {\n        $0.display(.flex)\n    }\n```\n\n### Inline SVG\n\n```swift\nInlineSVG {\n    svg(width: 100, height: 100) {\n        circle(cx: 50, cy: 50, r: 40)\n            .fill(\"red\")\n            .stroke(\"black\")\n            .strokeWidth(3)\n    }\n}\n\n// Raw SVG string\nsvg(\"\u003csvg width=\\\"50\\\" height=\\\"50\\\"\u003e\u003ccircle cx=\\\"25\\\" cy=\\\"25\\\" r=\\\"20\\\" fill=\\\"blue\\\"/\u003e\u003c/svg\u003e\")\n\n// SVG as data URI in img tag\nimg(svg: svgContent, alt: \"Icon\", base64: false)\n```\n\n### Rendering\n\n```swift\n// To string (minified by default)\nlet html = try String(document)\n\n// Pretty-printed\ntry HTML.Context.Configuration.$current.withValue(.pretty) {\n    let pretty = try String(document)\n}\n\n// To bytes\nlet bytes = [UInt8](document)\n```\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                        swift-html                            │\n│                    (unified re-export)                       │\n├─────────────────────────────────────────────────────────────┤\n│  swift-html-rendering  │  swift-css  │  swift-svg  │  ...   │\n│  (HTML.View, Document) │  (.css API) │  (SVG DSL)  │        │\n├─────────────────────────────────────────────────────────────┤\n│         swift-standards (CSS Standard, Color, etc.)          │\n└─────────────────────────────────────────────────────────────┘\n```\n\n**Re-exported modules:**\n\n| Module | Purpose |\n|--------|---------|\n| `HTML_Rendering` | Core HTML.View protocol and rendering |\n| `CSS` | Fluent CSS API with dark mode |\n| `CSS_Theming` | Theme system with semantic colors |\n| `SVG` | Type-safe SVG generation |\n| `Markdown_HTML_Rendering` | Markdown to HTML |\n| `Standards` | Layout, geometry types |\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n| **Type-safe HTML** | HTML5 elements with compile-time validation |\n| **Fluent CSS** | `.css.display(.flex).padding(.px(16))` chaining |\n| **Dark mode** | `DarkModeColor(light:dark:)` with automatic media queries |\n| **Theming** | Semantic color system (`.text.primary`, `.background.elevated`) |\n| **Layout** | HStack, VStack, Spacer, LazyVGrid components |\n| **SVG** | Inline SVG with type-safe elements |\n| **Media queries** | `.media(.minWidth(.px(768))) { ... }` |\n| **Rendering** | Single-pass byte rendering, pretty-print option |\n| **i18n (optional)** | TranslatedString support via \"Translating\" trait |\n\n### Optional: Translating Trait\n\nEnable internationalization support:\n\n```swift\n// Package.swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-html\", from: \"0.1.0\",\n             traits: [\"Translating\"])\n]\n```\n\nUsage:\n\n```swift\nimport HTML\nimport Translating\n\nlet greeting = TranslatedString(\n    dutch: \"Welkom\",\n    english: \"Welcome\"\n)\n\nh1 { greeting }\n```\n\n## Requirements\n\n- Swift 6.2+\n- macOS 26.0+, iOS 26.0+, tvOS 26.0+, watchOS 26.0+\n- Xcode 26.0+ (for Apple platforms)\n\n## License\n\nApache 2.0 - See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoenttb%2Fswift-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-html/lists"}