# ChatLayout builds a chat interface on UICollectionViewLayout

> ChatLayout is a Swift layout object for iOS that renders a message list inside a plain UICollectionView, so the developer keeps control of the cells, the data source and the keyboard. It is aimed at engineers replacing or avoiding a full chat framework.

**ekazaev/ChatLayout** — ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.

- Repository: https://github.com/ekazaev/ChatLayout
- Stars: 1,059 · Forks: 87
- Language: Swift
- License: MIT
- Published: 2026-10-19 · Updated: 2026-10-19 · Language: en
- Canonical page: https://hysenlabs.com/projects/ekazaev-chatlayout

## A chat list that stays inside a plain UICollectionView

ChatLayout presents itself as an alternative to MessageKit, and the alternative is not cosmetic. It is a custom UICollectionViewLayout object, and the whole design follows from that choice. A layout subclass sits underneath a collection view and decides where cells land and how large they are. It does not need to own your view controller, your collection view, or the views inside the cells.

The audience is an iOS engineer who has decided that a full messaging framework gives away too much. If you already have a message model, a design system and a navigation stack, the value of a library is in the parts it does not force on you: the layout math for variable height bubbles, the scroll behaviour during an update, and the ability to pin a header while the list moves.

The stated feature set is specific. Cells may have dynamic sizes. Insertion, deletion, reloading and moving are animated. During an update, the content of the last visible item is kept at the top or the bottom of the collection view, which is what stops a chat jumping when a new message arrives. There is tooling for precise scrolling to a required item, generic container views are shipped to speed up custom item construction, and pinned cells can behave like headers and footers.

A newer addition is agent mode support, described in the README as the often asked for case, with animated demonstrations in the assets folder of the repository.

## No upside-down collection view, no patched flow layout

The mechanism that separates ChatLayout from a typical chat list implementation is worth spelling out, because the README makes a point of it. ChatLayout does not rely on a modified UICollectionViewFlowLayout, and it does not rotate your UICollectionView upside down. The upside down trick is the traditional shortcut for making a chat grow from the bottom, and it carries a cost: every cell, every gesture and every layout calculation in the app has to think about the reversed coordinate space.

Because ChatLayout avoids that, your views behave like regular cells within a UICollectionView. A direct consequence is that the default UIKit implementations of adjustedContextInsets, and other system behaviours, work for you. Your view controller remains a normal view controller without hacks, as the README puts it.

The layout also stays out of your data model. Nothing is enforced about how you store messages or how you update the collection view. The only requirements are the natural boundaries of UICollectionView and a correct implementation of UICollectionViewDataSource. The Example app uses the provided ChatLayoutDiffableDataSource, but any diffing approach works, and the README points at DifferenceKit as an example of an alternative.

The same freedom applies to the cell views. There are generic UIView classes bundled with the library that may make building items faster, but you are not obliged to use them. That is a trade-off: you get less convenience, and you also avoid a library locking your bubble design into its own view types.

## Auto layout decides cell size, estimates decide speed

A layout has to know how tall a cell is before it can place things, and chat bubbles are rarely a fixed height. ChatLayout handles this by not requiring you to compute every cell size up front. You can use auto layout constraints and let the correct size be calculated at runtime, which is a large convenience for anyone whose bubbles contain dynamic text, timestamps or images.

The README is honest about the cost of that convenience. ChatLayout, like any UICollectionViewLayout, benefits from you providing estimated sizes of your cells, because the estimates allow better performance. The estimate is not a requirement for correctness, but it is the lever that keeps a long conversation scrolling smoothly. Teams that ignore it are trading frame rate for convenience without deciding to.

Cell size therefore depends on the runtime layout pass rather than on a precomputed array, and the layout reads it from the cells the collection view asks for. That is also why the layout is a good fit for content that arrives and changes: an insertion can be animated while the newly sized cell settles, and the position of the last visible item is preserved so the reading position does not move under the user.

Pinned cells extend the same idea. They can behave like headers or footers, staying in place while the list scrolls, which covers a common chat pattern of a date separator or a context banner at the top of the thread.

## Installing through CocoaPods, Carthage or SwiftPM

ChatLayout is distributed through all three of the usual Swift dependency managers. The repository root contains a Package.swift file and a ChatLayout.podspec, and the project publishes a Swift Package Manager and a Carthage compatibility badge. The Swift version named in the badges is 6.3, and the platform badge covers iOS 15 through iOS 27.

With CocoaPods, the whole package is installed by adding one line to your Podfile:

```
pod 'ChatLayout'
```

If the additional components in the package are not needed, the layout alone is available as a subspec:

```
pod 'ChatLayout/Core'
```

The Example project that ships in the repository is the fastest way to see the layout working. The README instruction is to clone the repo and run the install step from the Example directory first:

```
pod install
```

The Example directory also contains a Podfile, a Podfile.lock and a workspace file, which is the setup a chat screen usually needs to work on. Detailed usage guidance lives in the generated documentation site referenced from the README, and the Example app is described as the place to see the usage details.

## The keyboard and the input bar stay with you

The most useful section of the README is the one titled as what ChatLayout does not provide. Two omissions matter most in practice.

The first is keyboard appearance behaviour. ChatLayout does not handle it. You implement it from scratch or use the library already in your project, and the only thing ChatLayout asks is that you update the contentInsets of your UICollectionView. In exchange you get full control over the keyboard presentation, which is what teams with custom composer animations, a bottom toolbar or an accessory view need.

The second is input control. No input bar is provided. The Example app uses InputBarAccessoryView, but that is a choice of the example, not a requirement of the layout. Neither is the other way round: ChatLayout does not depend on MessageKit for the keyboard or for anything else, which is the whole point of the alternative.

None of this is free. An engineer adopting ChatLayout is taking on the composer, the keyboard insets, the cell views and the data source contract, all of which a bundled framework would have handed over. The exchange is stated plainly in the README: no need to extend or override a custom UIViewController or UICollectionView, because you instantiate them yourself and use them as you like. For a team with an existing design system that is a good trade. For a team that wants a working chat screen this week, it is a large amount of work to save a dependency.

## A young release line with one open quality item

ChatLayout is a Swift 6.3 project targeting iOS 15 and later, published under the MIT licence with the LICENSE file at the root of the repository. The README states that the project is in active development and welcomes contributions, and points to contribution guidelines hosted in another repository by the same author.

The release cadence is fast. Versions 2.5.0, 2.5.1 and 2.5.2 were published on 2026-09-16, 2026-09-18 and 2026-09-21, and the last push to the repository was on 2026-09-21. Recent changes arriving within a week of each other usually mean a fix is already in flight for whatever you are about to integrate, which is convenient for an actively developed library and also means the version you pin today may not be the version you pin next week.

The Todo list in the README is short and open. The item Improve the test coverage is unchecked, and further entries are grouped under headings about UICollectionViewDiffableDataSource, texture and animation, and those headings mark the areas the author still treats as open. A team that depends on exact animation behaviour should read the documentation site for the current state of those areas rather than assume they are settled.

Adopting the library also means adopting its upstream, a single maintainer, and a licence that is permissive but your own legal review still has to cover.

## Conclusion

ChatLayout suits iOS engineers who want a message list they can style with ordinary cells and auto layout, and who would rather own the keyboard and input bar than inherit them from a framework. It does not suit teams that want a drop in chat screen, because the keyboard behaviour, the input control and the cell views are all left to you, and the README is explicit about that. Before adopting it, check three things in the Example app: that the auto layout cell sizes you need are supported at your deployment target, which runs from iOS 15 to iOS 27, that the diffing solution you already use fits the data source contract the layout expects, and that the open test coverage item in the project Todo list does not block your own test plan. Install it with pod 'ChatLayout' and run the Example before writing the first real cell.

## FAQ

### What is ChatLayout and how does it differ from MessageKit?

ChatLayout is a custom UICollectionViewLayout for iOS, presented in the README as an alternative to MessageKit. The difference in approach is that ChatLayout is only a layout: it does not own your view controller, your data model, your cell views, the keyboard behaviour or the input bar, and it does not rotate the collection view upside down the way a traditional chat list does.

### How do I install ChatLayout in an iOS project?

It is available through CocoaPods, Carthage and SwiftPM. With CocoaPods the whole package is pod 'ChatLayout' and the layout alone is pod 'ChatLayout/Core'. To try the Example project, clone the repo and run pod install from the Example directory first.

### Does ChatLayout support variable height message cells?

Yes. It supports dynamic cell sizes and does not require you to calculate all cell sizes before rendering, so you can use auto layout constraints and let the size be computed at runtime. The README notes that providing estimated cell sizes still helps performance.

### Who handles the keyboard and the message input field in ChatLayout?

You do. ChatLayout does not handle keyboard appearance behaviour and does not provide any input control; the only requirement is that you update the contentInsets of your UICollectionView. The Example app uses InputBarAccessoryView for the composer, but that is an example choice rather than a library dependency.

### Can I use my own diffing library with ChatLayout?

Yes. The layout does not enforce a data model, and the only requirement is to respect the boundaries of UICollectionView and implement UICollectionViewDataSource correctly. The Example app uses the provided ChatLayoutDiffableDataSource, and the README names DifferenceKit as an alternative.

## Sources

- [ekazaev/ChatLayout on GitHub](https://github.com/ekazaev/ChatLayout)
- [Issues](https://github.com/ekazaev/ChatLayout/issues)
- [License: MIT](https://github.com/ekazaev/ChatLayout/blob/master/LICENSE)
- [README](https://github.com/ekazaev/ChatLayout/blob/master/README.md)
- [Releases](https://github.com/ekazaev/ChatLayout/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/ekazaev-chatlayout
