A theme in PrismUI is a concrete implementation of theDocumentation 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.
PrismTheme protocol that maps every ColorToken to a Color. Themes live in the SwiftUI environment, so every component below the injection point — no matter how deeply nested — automatically reads the right color without you passing anything explicitly. Switching themes at runtime triggers a re-render of the entire tree.
Built-in themes
PrismUI ships four themes that cover the most common needs.DefaultTheme
Apple HIG system colors with automatic light/dark adaptation. The right choice for most apps.
DarkTheme
Always-dark surfaces regardless of the system appearance setting. Useful for media players and cinematic sections.
HighContrastTheme
Maximum contrast beyond WCAG AAA. Use for accessibility-first products or as an opt-in user preference.
BrandTheme
Configurable primary, secondary, and accent colors. The right choice when you need to match a brand identity.
Applying a theme
Inject a theme into any view hierarchy with.prismTheme(). Place it at the root of your app to apply it everywhere, or on a specific subtree to scope it.
ColorScheme override using .prismEnvironment():
BrandTheme
BrandTheme accepts three Color values — primary, secondary, and accent — and maps them to the brand, variant, and interactive token roles respectively. All other tokens (backgrounds, surfaces, borders, feedback colors) remain consistent with the system defaults.
Auto-generated color harmonies
PrismAutoTheme derives a complete BrandTheme from a single brand color using color theory. Four harmony strategies are available:
Harmony enum when you want to pick a strategy dynamically:
Persisted theme switching with PrismThemeStore
PrismThemeStore persists the user’s theme choice to @AppStorage and restores it on next launch. It supports animated transitions between themes.
Create and inject the store
Create a
PrismThemeStore at the app level and apply it with .prismThemeStore(). The store starts with DefaultTheme and restores any previously saved preference automatically.Register custom themes
Register additional themes by identifier before injecting the store, or at runtime.
Implementing the PrismTheme protocol
For full control over every color role, implementPrismTheme directly. Your type must be Sendable and annotated with @MainActor.
Your
color(_:) method must handle all 28 ColorToken cases. The Swift compiler will warn you if you miss one, because ColorToken is a non-exhaustive enum — add a default fallback only if you intentionally want to inherit a base style.Reading the active theme in custom components
Access the current theme in any view using theprismTheme environment value: