Skip to content

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.

License

Notifications You must be signed in to change notification settings

Charlyk/swift-theme-kit

Repository files navigation

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

About

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.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages