Showcase is a Swift package designed to simplify the process of documenting and showcasing SwiftUI-based components. It provides a structured approach to create, organize, and present documentation for your SwiftUI projects. Showcase offers a variety of customization options and styles for presenting code samples, previews, and more.
- Structured documentation for SwiftUI components.
- Showcase your SwiftUI views' previews.
- Showcase libraries and chapters for organized content.
- Link external resources or documentation.
- Display code samples with syntax highlighting.
- Various styles for code blocks, previews, and external links.
- iOS 15+
- Xcode 13+
- Swift 5.7+
You can easily integrate Showcase into your Xcode project using Swift Package Manager. Follow these steps:
- Open your project in Xcode.
- Go to "File" -> "Swift Packages" -> "Add Package Dependency..."
- Enter the following URL when prompted: https://github.com/ipedro/swiftui-showcase
- Choose the version or branch you want to use.
- Click "Finish" to add the package to your project.
Alternatively, you can add Showcase as a dependency in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/ipedro/swiftui-showcase", from: "0.3.0")
]
Also: Don't forget to add "Showcase"
as a dependency of your package's target.
-
Import the Showcase module in your SwiftUI view file:
import Showcase
-
Create and structure your showcase topics using
Topic
instances.
The Showcase
view is used to display your showcase topics. Here's an example:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
// Create a Showcase with a Topic, e.g., .card
Showcase(.mockCard)
.navigationTitle("Component Showcase")
}
}
}
The ShowcaseList
view allows you to list chapters of showcase topics. Here's an example:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
// Create a list with two chapters
ShowcaseList(
Chapter("Section 1", .card, .accordion),
Chapter("Section 2", .button, .text)
)
.navigationTitle("Component Showcase")
}
}
}
The ShowcaseNavigationView
view provides navigation to chapters of showcase topics. Here's an example:
import SwiftUI
struct ContentView: View {
var body: some View {
// Create a ShowcaseNavigationView with a Chapter and optional icon
ShowcaseNavigationStack(
ShowcaseChapter(
"My Chapter",
Chapter("Section 1", .card, .accordion),
Chapter("Section 2", .button, .text)
)
)
}
}
Showcase is released under the MIT License. See LICENSE for details.
Contributions are welcome! Please see our Contribution Guidelines for more information.
Showcase is created and maintained by Pedro Almeida.