explaingit

slackhq/panmodal

3,786SwiftAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A Swift library from Slack that makes it easy to add sliding bottom sheet panels to iOS apps, handling all gesture recognition, animation, and transition logic so you don't have to build it from scratch.

Mindmap

mindmap
  root((PanModal))
    What it does
      Bottom sheet modals
      Gesture handling
      Smooth animations
    Setup
      One line to present
      PanModalPresentable
      panScrollable property
    Height modes
      shortFormHeight
      longFormHeight
      Dynamic updates
    Installation
      CocoaPods
      Carthage
      Swift Package Manager
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Show a card-style action sheet that slides up from the bottom of your iOS screen.

USE CASE 2

Build a bottom panel users can expand, collapse, or dismiss by swiping, like Slack's own UI.

USE CASE 3

Display a settings or detail view as a half-screen overlay without navigating away from the current screen.

USE CASE 4

Add a scrollable bottom sheet where dragging the content list also collapses the sheet.

Tech stack

SwiftCocoaPodsCarthageSwift Package Manager

Getting it running

Difficulty · easy Time to first run · 30min

Requires iOS 10+ and Swift 4.2+, one line of code to present the first sheet.

Use freely in personal and commercial projects as long as you keep the copyright notice.

In plain English

PanModal is a Swift library from Slack that makes it easier to show bottom sheet modals in iOS apps. A bottom sheet is a panel that slides up from the bottom of the screen, letting users interact with content without leaving the current view. PanModal handles the gesture recognition, animation, and transition so developers do not have to build this from scratch. Getting started requires one line of code: call presentPanModal with the view controller you want to display. The view controller needs to adopt the PanModalPresentable protocol, which asks it to declare a panScrollable property. If the content includes a scrollable list such as a table view, pointing panScrollable at that scroll view lets PanModal coordinate pan gestures between the bottom sheet drag handle and the content inside it. Scrolling down when the sheet is expanded can collapse it, pulling up expands it again. Two height configurations are available: shortFormHeight for a compact position, and longFormHeight for the fully expanded state. Both can be set to fixed pixel values or configured to fill the screen with a top inset. If the height needs to change after the sheet is already visible, calling panModalSetNeedsLayoutUpdate tells the library to recalculate and animate to the new size. The library requires iOS 10 or later and is compatible with Swift 4.2 and 5. It can be installed through CocoaPods, Carthage, or Swift Package Manager. A sample app in the repository shows more involved setups including navigation controllers and stacked modals. PanModal was built by Slack for use in its own iOS application and is open sourced under the MIT license. The team notes they address only critical bugs, non-critical improvements are left to the community.

Copy-paste prompts

Prompt 1
Using PanModal, show me how to present a bottom sheet modal with a UITableView inside it that supports both compact and expanded height states.
Prompt 2
How do I update the height of a PanModal bottom sheet after it's already visible on screen?
Prompt 3
Write Swift code using PanModal to present a custom view controller as a bottom sheet with a shortFormHeight of 300 points and a longFormHeight that fills the screen.
Prompt 4
How do I stack two PanModal sheets on top of each other in an iOS app?
Prompt 5
Set up a PanModal sheet with a UIScrollView so scrolling up expands the sheet and scrolling down collapses it.
Open on GitHub → Explain another repo

← slackhq on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.