Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt

Use this file to discover all available pages before exploring further.

This guide takes you from zero to a running Prism screen. You’ll add the package, inject a theme into your app’s root view, render a PrismButton with an async action, and validate a PrismTextField — all using the design token modifiers that keep your UI consistent across every Apple platform.
1

Add Prism to Package.swift

Open your Package.swift and add Prism to your dependencies array, then declare it as a dependency of your target.
// Package.swift
dependencies: [
    .package(url: "https://github.com/rafaelesantos/prism.git", from: "1.0.0")
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "Prism", package: "prism")
        ]
    )
]
If you’re working in an Xcode project instead, go to File → Add Package Dependencies, paste the URL above, and add the Prism product to your app target.
2

Apply a theme to your root view

Prism’s design system activates when you inject a theme into the SwiftUI environment. Call .prismTheme(_:) on your app’s root view — every component nested inside will automatically read colors, typography, and spacing from the active theme.
import SwiftUI
import Prism

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .prismTheme(DefaultTheme())
        }
    }
}
DefaultTheme uses Apple HIG system colors and adapts automatically to light and dark mode. To match your brand, substitute BrandTheme:
let theme = BrandTheme(primary: .indigo, secondary: .mint, accent: .orange)

ContentView()
    .prismTheme(theme)
3

Add a PrismButton with an async action

PrismButton wraps an async closure and automatically shows a loading indicator while the action runs. Pass a variant to control the visual style.
import SwiftUI
import Prism

struct SignInView: View {
    var body: some View {
        PrismButton("Sign In", variant: .filled) {
            await viewModel.signIn()
        }
    }
}
Available variants are .filled, .tinted, .bordered, .plain, .glass, and .glassProminent. The button disables itself while the action is in flight — no additional state management required.
4

Add a PrismTextField with validation

PrismTextField accepts a Validation rule that runs when the field loses focus. The error message appears automatically below the field using the theme’s error color.
import SwiftUI
import Prism

struct SignInView: View {
    @State private var email = ""

    var body: some View {
        PrismTextField(
            "Email",
            text: $email,
            validation: .pattern(
                "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}",
                "Enter a valid email address"
            )
        )
    }
}
Other built-in rules are .required(_:), .minLength(_:_:), .maxLength(_:_:), and .custom(_:) for arbitrary logic.
5

Style views with semantic modifiers

Rather than hardcoding colors and sizes, use Prism’s semantic modifier API. Each modifier reads from the active theme, so your views adapt automatically when the theme changes.
Text("Welcome back")
    .prismFont(.title)
    .prismColor(.onBackground)
    .prismPadding(.lg)
    .prismSurface(.surfaceSecondary, radius: .lg)
ModifierWhat it does
.prismFont(_:)Applies a TypographyToken — maps to Apple’s Dynamic Type styles
.prismColor(_:)Sets foregroundStyle using a ColorToken resolved by the active theme
.prismPadding(_:)Applies uniform padding using a SpacingToken from the 4pt grid
.prismSurface(_:radius:)Applies a themed background color with a continuous corner radius
Combine these modifiers to build cards, labels, and containers that stay visually consistent without any magic numbers.
Prism requires Swift 6.3, Xcode 16.4 or later, and a minimum deployment target of iOS 26, macOS 26, tvOS 26, watchOS 26, or visionOS 26. These targets are set deliberately high so that PrismUI can use the latest SwiftUI APIs without availability guards.