A Swift package that provides a strongly-typed domain model of CSS properties and values. The CSS types in this package closely mirror the CSS specification, enabling compile-time validation of CSS property values.
This package is currently in active development and is subject to changes. Features and APIs may change without prior notice until a stable release is available.
- Type-safe CSS properties and types: All CSS properties and types represented as Swift types
- Goal of complete CSS coverage: At-rules, combinators, functions, pseudo-classes, pseudo-selectors, and selectors are a work in progress
- Bring Your Own integration: Designed as a foundation for Swift packages that provide a Swift CSS Domain Specific Language (DSL)
import CSS
// Create type-safe CSS values
let color: CSS.Color = .rgba(red: 100, green: 149, blue: 237, alpha: 1) // rgb(100, 149, 237)
let fontSize: Length = 24.px // 24px
// Create type-safe CSS properties
let backgroundColor = BackgroundColor(color)
let fontSizeProperty = FontSize(fontSize)
Add the dependency in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/coenttb/swift-css-types", from: "0.0.1")
]
- Select File > Add Packages...
- Enter package URL:
https://github.com/coenttb/swift-css-types
- Select version 0.0.1 or "Up to Next Major Version"
- swift-html-types: A Swift package that provides a strongly-typed domain model of HTML elements and attributes.
- swift-html: A Swift DSL for domain-accurate and type-safe HTML & CSS.
- swift-web: Foundational tools for web development in Swift.
- coenttb-com-server: 100% Swift server & website, built in
swift-html-types
.
Contributions are welcome! Please feel free to submit a Pull Request.
If you have suggestions or find issues, please open a GitHub issue. Your feedback helps make this project better for everyone.
This project is licensed under the Apache 2.0 License. See LICENSE for details.