A framework and generator for displaying SwiftUI component libraries



Exhibition is a framework and generator for displaying and debugging a SwiftUI component library.

Inspired by Storybook and Showkase


Swift Package Manager

  1. Add https://github.com/mjarvis/Exhibition to your project via Xcode.
  2. Install Sourcery
  3. Copy Exhibition.swifttemplate into your project


  1. Modify your SwiftUI previews to use ExhibitProvider
    import Exhibition
    struct Foo_Previews: ExhibitProvider, PreviewProvider {
        static var exhibitName: String = "Foo"
        static var exhibitSection: String = "Bar"
        static func exhibitContent(context: Context) -> some View {
                title: context.parameter(name: "title", defaultValue: "Title"),
                content: context.parameter(name: "content")
  2. Run Sourcery to generate your Exhibition: sourcery --sources Your/Source/Path --templates Exhibition.swifttemplate --output ./Sources/Generated
  3. Show Exhibition() in a swift view

Custom Layout

If you would like your exhibit to have some custom layout, there is an optional function in ExhibitProvider you can implement.

Here is an example of embeding the exhibit within a List:

static func exhibitLayout(content: AnyView) -> some View {
    List {

You can also provide a custom View here to provide presentation samples:

struct CustomLayout<Content: View>: View {
    let content: Content
    @State var isPresented: Bool = false
    var body: some View {
        Button("Open") {
            isPresented = true
        .sheet(isPresented: $isPresented) {

static func exhibitLayout(content: AnyView) -> some View {
    CustomLayout(content: content)

Custom Parameter views

Exhibition supports a number of types in the parameter list of the debug menu. You can add your own arbitrary types along with a view to modify the parameter, or override the views for existing types. Conform to ParameterView, and pass the type in via the .parameterView modifier on Exhibition.

struct DoublingStringParameterView: ParameterView {
    let key: String
    @Binding var value: String
    var body: some View {
        Button(key) {
            value += value



  • Swift Tools 5.5.0
View More Packages from this Author


  • None
Last updated: Tue Nov 08 2022 12:59:03 GMT-0500 (GMT-05:00)