Installation
Get PrettyUI up and running in your SwiftUI project in under 5 minutes.
Requirements
| Platform | Minimum Version |
|---|---|
| iOS | 15.0+ |
| macOS | 12.0+ |
| tvOS | 15.0+ |
| watchOS | 8.0+ |
| Xcode | 14.0+ |
| Swift | 5.7+ |
Swift Package Manager
Option 1: Using Xcode
The easiest way to add PrettyUI to your project:
- Open your project in Xcode
- Go to File → Add Package Dependencies...
- Paste the repository URL in the search field:
https://github.com/ajagatobby/PrettyUI.git
- Select "Up to Next Major Version" starting from
1.0.0 - Click Add Package
Option 2: Using Package.swift
For Swift packages or command-line projects, add PrettyUI as a dependency:
// swift-tools-version: 5.7
import PackageDescription
let package = Package(
name: "MyApp",
platforms: [
.iOS(.v15),
.macOS(.v12),
.tvOS(.v15),
.watchOS(.v8)
],
dependencies: [
.package(
url: "https://github.com/ajagatobby/PrettyUI.git",
from: "1.0.0"
)
],
targets: [
.target(
name: "MyApp",
dependencies: ["PrettyUI"]
)
]
)
Quick Start
1. Import PrettyUI
import PrettyUI
2. Apply a Theme
Wrap your root view with a theme modifier. PrettyUI comes with 4 beautiful themes:
import SwiftUI
import PrettyUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.prettyTheme(.sky) // Apply the Sky theme
}
}
}
3. Use Components
Start building with PrettyUI components:
import SwiftUI
import PrettyUI
struct ContentView: View {
@State private var name = ""
@State private var showToast = false
var body: some View {
VStack(spacing: 24) {
// Text Field with label and placeholder
PTextField("Name", text: $name)
.withLabel("Your Name")
.withPlaceholder("Enter your name")
// Primary button with action
PButton("Say Hello", style: .primary) {
showToast = true
}
// Card with content
PCard {
VStack(alignment: .leading, spacing: 8) {
Text("Welcome!")
.font(.headline)
Text("This is a PrettyUI card component.")
.foregroundColor(.secondary)
}
}
}
.padding()
.pToast(isPresented: $showToast, variant: .success) {
Text("Hello, \(name.isEmpty ? "World" : name)!")
}
}
}
Available Themes
PrettyUI includes 4 professionally designed themes:
| Theme | Primary Color | Best For |
|---|---|---|
.sky | Cyan Blue (#1DA1F2) | Social, communication apps |
.indigo | Deep Purple (#5856D6) | Productivity, finance apps |
.emerald | Green (#34C759) | Health, nature apps |
.amber | Orange (#FF9500) | Creative, entertainment apps |
Switching Themes
You can change themes dynamically:
struct SettingsView: View {
@State private var selectedTheme: PrettyTheme = .sky
var body: some View {
VStack {
Picker("Theme", selection: $selectedTheme) {
Text("Sky").tag(PrettyTheme.sky)
Text("Indigo").tag(PrettyTheme.indigo)
Text("Emerald").tag(PrettyTheme.emerald)
Text("Amber").tag(PrettyTheme.amber)
}
.pickerStyle(.segmented)
// Preview with selected theme
ContentView()
.prettyTheme(selectedTheme)
}
}
}
What's Next?
Now that you have PrettyUI installed, explore:
- Theming — Learn how to customize and create your own themes
- Design Tokens — Understand the token system for colors, spacing, and more
- Button — Start with the most commonly used component