An open API service indexing awesome lists of open source software.

https://github.com/charlyk/swift-theme-kit

SwiftThemeKit is a powerful and flexible design system framework for SwiftUI that enables you to create consistent, themeable user interfaces with ease. It provides a comprehensive set of components and utilities that follow modern design principles while maintaining full customizability.
https://github.com/charlyk/swift-theme-kit

ios ios-app ios-swift macos macos-app swift swiftui theme-switcher themes theming theming-library

Last synced: 3 months ago
JSON representation

SwiftThemeKit is a powerful and flexible design system framework for SwiftUI that enables you to create consistent, themeable user interfaces with ease. It provides a comprehensive set of components and utilities that follow modern design principles while maintaining full customizability.

Awesome Lists containing this project

README

          

![logo](logo.png)

# SwiftThemeKit

**A modern, token-driven design system framework for SwiftUI**
Easily create consistent, themeable user interfaces with full customization power โ€” powered by a scalable design token system and environment-based styling.

[![SwiftPM](https://img.shields.io/badge/SwiftPM-Compatible-blue)]()
[![iOS](https://img.shields.io/badge/iOS-14.0%2B-lightgrey)]()
[![Version](https://img.shields.io/github/v/tag/Charlyk/swift-theme-kit?label=Version)]()
[![License](https://img.shields.io/badge/License-MIT-yellow)]()

SwiftThemeKit - A modern, token-driven design system framework for SwiftUI | Product Hunt


Demo app animation

---

## Theme builder [WIP]

[SwiftThemeKit.com](https://swiftthemekit.com)

## โœจ Why SwiftThemeKit?

SwiftUI offers flexibility, but theming across an entire app is hard to scale. SwiftThemeKit solves this by:

- ๐Ÿ”„ Applying themes globally using `@Environment`
- ๐Ÿงฑ Using design tokens (color, spacing, typography, shape, etc.)
- ๐Ÿ”ง Letting you override *just what you need*โ€”no subclassing or brittle modifiers
- ๐Ÿงช Supporting previewing themes and snapshot testing

---

## ๐Ÿ”ง Features

- ๐ŸŽจ Complete light & dark theming system with token override support
- ๐Ÿงฉ Drop-in UI components: `Button`, `TextField`, `Checkbox`, `Card`, `RadioGroup`, etc.
- ๐Ÿ’ก Declarative `.applyTheme*Style()` modifiers for composability
- โ™ฟ๏ธ Built with accessibility and contrast in mind
- ๐Ÿ”Œ Plug-and-play: just add `ThemeProvider` and you're ready

---

## ๐Ÿš€ Quick Start

1. **Wrap your root view with `ThemeProvider`:**

```swift
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ThemeProvider {
ContentView()
}
}
}
}
```

2. **Use themed components:**

```swift
struct ContentView: View {
@State private var isEnabled = false
@State private var username = ""

var body: some View {
VStack {
Button("Primary Button") { }
.applyThemeButtonStyle()

Checkbox(isChecked: $isEnabled, label: "Enable Feature")

TextField("Username", text: $username)
.applyThemeTextFieldStyle()
}
}
}
```

---

## ๐ŸŽจ Design Tokens

SwiftThemeKit uses a modular token-based system:

### ๐Ÿ–Œ Color Tokens
- `primary`, `secondary`, `error`, `background`, `surface`
- On-color variants: `onPrimary`, `onError`, etc.

### ๐Ÿ”ค Typography
- Display, headline, body, label, button fonts
- Font sizes, weights, line spacing

### ๐Ÿ“ Spacing & Shape
- Spacing: `xs`, `sm`, `md`, `lg`, `xl`, `xxl`
- Radius: corner tokens (`sm`, `md`, `lg`)
- Shadow elevations: `level1`, `level2`, `none`

---

## ๐Ÿงฉ Core Components

### โœ… Buttons
- Variants: `.filled`, `.tonal`, `.outlined`, `.elevated`, `.text`
- Role support (e.g., `.destructive` uses error color tokens)

### โœ… Inputs
- `TextField`: outlined, filled, underlined
- `Checkbox`, `RadioButton`, `RadioGroup`

### โœ… Card
- Customizable padding, elevation, background
- Shadow and shape tokens applied via environment

---

## ๐Ÿ›  Customizing Themes

You can create your own themes using token structs:

```swift
let customTheme = Theme(
colors: .customColors,
typography: .customTypography,
spacing: .customSpacing,
shapes: .customShapes
)
```

Or override parts of the environment:

```swift
MyView()
.font(.headlineMedium)
.padding(.xl)
.clipShape(.rounded)
```

---

## ๐Ÿ“ฆ Installation

Use [Swift Package Manager](https://swift.org/package-manager/) and select the latest release:

```swift
dependencies: [
.package(url: "https://github.com/Charlyk/swift-theme-kit.git", from: "")
]
```

---

## ๐Ÿงช Screenshots

Click to view full-size previews from snapshot tests:

- [Typography](DemoApp/SwiftThemeKitDemo/SwiftThemeKitDemoTests/__Snapshots__/SwiftThemeKitDemoTests/testExampleViewSnapshot.TypographyView.png)
- [Buttons](DemoApp/SwiftThemeKitDemo/SwiftThemeKitDemoTests/__Snapshots__/SwiftThemeKitDemoTests/testExampleViewSnapshot.ButtonsView.png)
- [Cards](DemoApp/SwiftThemeKitDemo/SwiftThemeKitDemoTests/__Snapshots__/SwiftThemeKitDemoTests/testExampleViewSnapshot.ShapesView.png)
- [Checkboxes](DemoApp/SwiftThemeKitDemo/SwiftThemeKitDemoTests/__Snapshots__/SwiftThemeKitDemoTests/testExampleViewSnapshot.CheckboxesView.png)

---

## ๐Ÿง  Best Practices

- Prefer `.applyTheme*Style()` over custom modifiers
- Use semantic tokens (e.g., `themeColor.primary`) instead of raw colors
- Override per-view styles using `View.theme*()` modifiers
- Preview multiple themes using SwiftUI `ForEach`

---

## ๐Ÿ“‹ Requirements

- iOS 14+, macOS 11+, tvOS 15+, watchOS 7+
- Swift 5.5+

---

## ๐Ÿค Contributing

We welcome issues and PRs!
Check the [CONTRIBUTING.md](CONTRIBUTING.md) for setup and guidelines.

---

## ๐Ÿ“„ License

MIT. See [LICENSE](LICENCE) for details.

---

## ๐Ÿ” Keywords

`swift`, `swiftui`, `design-system`, `ui-kit`, `dark-mode`, `theme`, `component-library`, `design-token`, `sdk`