SwiftThemeKit

1.2.4

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.
Charlyk/swift-theme-kit

What's New

1.2.4

2025-09-08T13:55:49Z

What's Changed

  • Rename navigation title modifier to avoid conflicts with system modifier by @Charlyk in #22

Full Changelog: 1.2.3...1.2.4

logo

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 iOS Version License

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

Demo app animation

Theme builder [WIP]

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:
@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ThemeProvider {
                ContentView()
            }
        }
    }
}
  1. Use themed components:
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:

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

Or override parts of the environment:

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

๐Ÿ“ฆ Installation

Use Swift Package Manager and select the latest release:

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

๐Ÿงช Screenshots

Click to view full-size previews from snapshot tests:


๐Ÿง  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 for setup and guidelines.


๐Ÿ“„ License

MIT. See LICENSE for details.


๐Ÿ” Keywords

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

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Tue Oct 28 2025 02:14:15 GMT-0900 (Hawaii-Aleutian Daylight Time)