One UI kit for every screen
Open KROMA on an Apple TV, on a Samsung TV and in your browser. A film's poster has the same size, the same rounded corners and the same glow when you select it. These are not three components kept in sync by hand. It is one file.
One component, two renderers
The whole kit, @kromatv/ui, is written for React Native. On devices that run
React Native, meaning Apple TV, Android TV, iPhone, iPad and Android, each
component becomes a real native element of the system.
Everywhere else it goes through react-native-web, a library that turns the same components into HTML and CSS. That covers the website, LG TVs, the app for Mac, Windows and Linux, and Samsung TVs. Samsung TVs from 2021 on can now run it natively too, thanks to react-native-tizen.
So you write a component once, and it has two ways to show up on screen.
Colors and sizes, defined once
Colors, typefaces, spacing and shadows are defined once, in TypeScript:
import { colors, typeSpec } from '@kromatv/ui/tokens';
colors.accent; // '#F4B642', the amber
colors.bg; // '#0A0A0C', the charcoal background
typeSpec.hero; // Bricolage Grotesque, 66 px, weight 700Native apps read these values directly. For web targets, the build turns them into CSS variables. There is no stylesheet to copy by hand, so nothing can drift out of sync.
These values are plain strings on purpose. No oklch(), no color-mix(). The
same value has to go unchanged into a React Native stylesheet, into a CSS
variable and into the browser of an old LG TV running Chromium 53. As soon as a
value needs computing, one of the three can no longer read it.
TV screens are drawn on a fixed 1920 by 1080 canvas. A number in the code is a pixel of the design, with no scale to remember.
This site, kroma.tv, imports the same tokens. That is why it has exactly the same amber as the app.
Focus is the hard part
A TV has no mouse. You move with the arrows on the remote, and on every press the app has to decide which element lights up next. Press right on a poster and you should land on its neighbour, not on a button at the other end of the screen.
At first we let the system handle it. Apple TV and Android TV have their own focus engine. TVs that run KROMA in a browser have none, so we computed the nearest neighbour in the pressed direction ourselves. Two engines, and over time they stopped behaving the same way. The same screen did not move the same way on an Apple TV and on a Samsung.
So we moved to one navigation library for every target. It fixed that problem and brought new ones. When a list registered the same element twice, the library crashed halfway through registering, and every element after that no longer existed for it. On screen, several posters lit up at once.
So we wrote our own, @kromatv/spatial-nav. We started with the tests, which
describe how focus has to move, then wrote the engine to pass them. Today an
Apple TV and a TV that runs KROMA in its browser move focus by exactly the same
rules.
One rule: no special cases in components
With two renderers, it is tempting to write if (Platform.OS === 'web') all
over the place. We don't allow it. No component checks the platform. The
differences live in one layer below the components, and a lint rule rejects code
that tries anyway.
When a platform behaves differently, we fix that layer, and every component gets the fix at once.
What it costs
Every build tool has to know how to swap React Native for react-native-web, and there are two renderers to test instead of one.
In return, changing a film's poster is one commit. Every app has it in its next release, the living room TV as much as the phone.