---
title: "ComponentKit"
url: https://deallocatedobjects.com/posts/componentkit
author: Jake Marsh
published: 2015-03-25
updated: 2015-03-25
link: http://componentkit.org/
topics: ["iOS Development", "Open Source"]
description: "ComponentKit takes a functional, declarative approach to building UI. It lets you focus on what your UI should look like, not the steps necessary to build it. It emphasizes a one-way data flow from immutable models to immutable components that describe how views should be configured."
---

# ComponentKit

By Jake Marsh, March 25, 2015. HTML: https://deallocatedobjects.com/posts/componentkit

This is a link post about http://componentkit.org/

<img src="https://deallocatedobjects.com/media/e760a076c42a.png" style="float: right; margin: 20px; margin-top: 40px; width: 159px;" />

> ComponentKit takes a functional, declarative approach to building UI. It lets you focus on what your UI should look like, not the steps necessary to build it. It emphasizes a one-way data flow from immutable models to immutable components that describe how views should be configured. It does the heavy lifting of building a view hierarchy from this description.

I've been waiting to play around with this library since I saw [this fantastic talk from Adam Ernst and Ari Grant](https://www.youtube.com/watch?v=mLSeEoC6GjU) late last year.

There's many pieces to ComponentKit, but one of the most interesting (to me at the moment) is it's declarative layout system:

_This is random code I copy/pasted together to show some examples of layout inside ComponentKit. Please refer to [their excellent documentation](https://web.archive.org/web/20150328180922/http://componentkit.org/docs/getting-started.html) to see the real thing._

``` objective-c
[CKInsetComponent
	newWithInsets:{.top = 70, .bottom = 25, .left = 20, .right = 20}
    component:
		[CKStackLayoutComponent 
 			newWithStyle:{
  				.direction = CKStackLayoutComponentDirectionVertical,
 			} 
			children:{
				{[HeaderComponent newWithArticle:article]},
				{[MessageComponent newWithArticle:article]},
				{[FooterComponent newWithArticle:article]},
			}
		]
];
```

I've been working in WatchKit quite a bit lately, and I've come to really enjoy it's layout system a lot. It's certainly limiting, but it's fantastic for quickly putting things together when you have an idea. I've been wishing a library would come along that emulated this sort of system for iOS in general, and ComponentKit fits the bill.

Even though some of the ideas and foundations in ComponentKit clash pretty heavily with UIKit's philosophies, I'm encouraged by the pure usability of their system. Even their choice of Objective-C++ as a language was made to make the end-resulting code that uses the library as readable as possible.

It's certainly not meant to be a catch-all and won't be the right choice for every app, but in the cases where it makes sense, ComponentKit seems like a slam dunk.
