Atomic Design with Compose Multiplatform

As mentioned in the previous post, From the napkin to wireframes, atomic design is the bridge from wireframes to code – and I promised the details of how Einsatzlog’s UI is structured. Here they are – as a general recipe for Compose Multiplatform, with notes on what Einsatzlog actually does at each step.
0) Terminology, so we’re aligned
- Atomic Design is a methodology for structuring a design system and component library. It is technology-agnostic. (Brad Frost, Atomic Design, chapter 2)
- Aqua was Apple’s original glassy macOS look, introduced in 2000 – historical context, not an iOS UI. (Wikipedia)
- With iOS 26, Apple introduced Liquid Glass: translucent, glass-edged, dynamically rendered materials across all its platforms. That is the modern reference point for “Aqua-like” UI on iOS. (Apple Newsroom)
1) Why Atomic Design for Compose Multiplatform?
Atomic Design gives you a scalable, testable way to build one shared UI library for Android and iOS (and Desktop or Web, if you target them). Compose Multiplatform lets you share UI code and ships a common Material 3 library, so the same components render natively on every target. (Compose Multiplatform)
In Einsatzlog: the targets are Android and iOS, and every component and screen body lives in a separate :ui module’s commonMain. The app module depends on it and adds only the thin wiring (ViewModels, DI, navigation); the screenshot generator (a JVM module) depends on it too – so the store screenshots are rendered from exactly the same components.
2) Project and package layout
A general layout:
composeApp/
src/
commonMain/kotlin/
design/
tokens/ // design tokens & theme
atoms/ // smallest building blocks
molecules/
organisms/
templates/
pages/
util/ // shared modifiers, semantics
androidMain/ // Android-only adaptations (e.g. dynamic colour)
iosMain/ // iOS-only adaptations (e.g. haptics)
Keep strings, images and fonts in shared code with Compose Multiplatform resources. They come with the Compose plugin; you only add the runtime dependency:
// build.gradle.kts (module)
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.material3) // AndroidX M3 on Android, JetBrains M3 elsewhere
implementation(compose.components.resources) // generated Res.string / Res.drawable / Res.font
}
}
}
(JetBrains: Multiplatform resources)
In Einsatzlog: ui/components/{atoms,molecules,organisms}, screens in ui/<feature>/, tokens in ui/theme/. German is the default resource set, English is complete; domain terms like Funkspruch stay German in both.
3) Foundations: design tokens
Treat tokens as the atoms beneath atoms. They are not UI; they are the rules your UI uses.
Create token types and expose them through CompositionLocals, so every level can read them without passing them down by hand:
@Immutable
data class Spacing(val xs: Dp = 4.dp, val sm: Dp = 8.dp, val md: Dp = 12.dp, val lg: Dp = 16.dp, val xl: Dp = 24.dp)
@Immutable
data class Radius(val sm: Dp = 8.dp, val md: Dp = 12.dp, val lg: Dp = 20.dp)
val LocalSpacing = staticCompositionLocalOf { Spacing() }
val LocalRadius = staticCompositionLocalOf { Radius() }
// A semantic palette, so atoms don't depend on Material 3 directly
@Immutable
data class AppColors(val surfaceGlass: Color, val onSurfaceGlass: Color, val brand: Color, val onBrand: Color)
val LocalAppColors = staticCompositionLocalOf {
AppColors(Color(0x33FFFFFF), Color(0xFF000000), Color(0xFF3563E9), Color.White)
}
A theme wrapper merges the tokens with Material 3:
@Composable
fun AppTheme(dark: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val colorScheme = if (dark) darkColorScheme() else lightColorScheme()
CompositionLocalProvider(
LocalSpacing provides Spacing(),
LocalRadius provides Radius(),
LocalAppColors provides LocalAppColors.current.copy(brand = colorScheme.primary, onBrand = colorScheme.onPrimary),
) {
MaterialTheme(colorScheme = colorScheme, typography = Typography(), content = content)
}
}
This is the same mechanism Material uses internally. (Android Developers: CompositionLocal)
In Einsatzlog the token level is called particles. Spacing is a plain object (including a 48 dp touchTarget for gloves), and the one token set that really needs a CompositionLocal is the message-type colour coding, because it changes between light and dark:
@Immutable
data class EntryTypeColors(val funkspruch: TypeColorPair, val lagemeldung: TypeColorPair, /* … */) {
operator fun get(type: MessageType): TypeColorPair = when (type) { /* … */ }
}
val LocalEntryTypeColors = staticCompositionLocalOf { LightEntryTypeColors }
// EinsatzlogTheme
CompositionLocalProvider(
LocalEntryTypeColors provides if (darkTheme) DarkEntryTypeColors else LightEntryTypeColors,
) { MaterialTheme(colorScheme = if (darkTheme) DarkColors else LightColors, content = content) }
4) Rules per level
Atoms
Goal: one job, no state, modifier first, values from tokens.
- Stateless; hoist state to the parent.
- Take
modifier: Modifier = Modifierand use tokens instead of hard-coded values. - Offer slots (icon, label) where it keeps the atom flexible.
- No business logic; accessibility semantics built in.
@Composable
fun PrimaryButtonAtom(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
leading: (@Composable () -> Unit)? = null,
) {
val s = LocalSpacing.current
val c = LocalAppColors.current
Button(
onClick = onClick,
enabled = enabled,
modifier = modifier.heightIn(min = 48.dp),
colors = ButtonDefaults.buttonColors(containerColor = c.brand, contentColor = c.onBrand),
contentPadding = PaddingValues(horizontal = s.lg, vertical = s.sm),
) {
if (leading != null) { leading(); Spacer(Modifier.width(s.sm)) }
Text(text)
}
}
In Einsatzlog: TypeChip is the archetypal atom – one message type in, one colour-coded label out, colours from LocalEntryTypeColors.
Molecules
Goal: a composition of atoms; minimal state; events go up.
@Composable
fun SearchFieldMolecule(
value: String,
onValueChange: (String) -> Unit,
onSubmit: () -> Unit,
placeholder: String,
modifier: Modifier = Modifier,
) {
val s = LocalSpacing.current
Row(modifier, verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Default.Search, contentDescription = null)
Spacer(Modifier.width(s.sm))
OutlinedTextField(
value = value,
onValueChange = onValueChange,
placeholder = { Text(placeholder) },
modifier = Modifier.weight(1f),
singleLine = true,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = { onSubmit() }),
)
}
}
In Einsatzlog: EntryTypeSelector (a row of type chips), SuggestionChipRow (learned call signs), SupportTierCard.
Organisms
Goal: a distinct section of a screen; internal state only where it’s a pure UI concern.
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AppTopBarOrganism(title: String, onBack: (() -> Unit)? = null, actions: @Composable RowScope.() -> Unit = {}) {
TopAppBar(
title = { Text(title) },
navigationIcon = { onBack?.let { IconButton(onClick = it) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back") } } },
actions = actions,
)
}
In Einsatzlog: QuickEntryForm (time, type, from/to with suggestions, message), LogEntryStream, EinsatzHeader.
Templates and pages
Templates are the layout scaffolding without real content; pages put real content into templates – that’s where product logic meets the UI hierarchy.
@Composable
fun TwoPaneTemplate(sidebar: @Composable ColumnScope.() -> Unit, content: @Composable ColumnScope.() -> Unit) {
Row(Modifier.fillMaxSize()) {
Column(Modifier.width(300.dp).fillMaxHeight().padding(16.dp), content = sidebar)
VerticalDivider()
Column(Modifier.weight(1f).padding(16.dp), content = content)
}
}
In Einsatzlog these two levels collapse into one: screens. Each has a stateless *Content composable (the page, fully previewable) and a thin *Screen wrapper in the app module that gets its ViewModel from Koin and hoists the state. A phone-only app with five screens didn’t need a separate template layer – and adding one later is cheap because the rule “only depend downwards” already holds.
5) Patterns that hold up
- State hoisting: atoms never own state; molecules may hold ephemeral state (focus) but emit canonical state upwards.
- Slots over flags:
leading,trailing,actionsinstead of boolean parameters that multiply variants. - Stability:
@Immutableon token and data classes; stable parameters; chain modifiers instead of adding wrapper layouts. - Accessibility first:
contentDescription,semantics { }, at least 48 dp touch targets. - Keep atoms portable: build neutral foundations and wrap Material 3 where needed, so the same atoms could adopt another design language.
- Resource discipline: strings, fonts and images in
composeResources/, accessed viaRes.*on every platform. - In Einsatzlog, one more: every molecule and organism has an
@Preview, and the preview gallery doubles as living documentation.
6) One Material 3, every platform
With Compose Multiplatform you reference one MaterialTheme in common code. On Android the Gradle metadata resolves it to androidx.compose.material3:material3; on iOS and other targets to JetBrains’ org.jetbrains.compose.material3:material3. Your atoms can call MaterialTheme.colorScheme and it just works everywhere. (JetBrains: Compose Multiplatform and Jetpack Compose)
7) “Glass” as a reusable surface atom
Liquid Glass is about translucency, glass-edge highlights and dynamic blur. To build a compatible surface in Compose Multiplatform, use Haze, a multiplatform backdrop-blur library, and put your tokens on top. Haze separates the content that gets blurred (hazeSource) from the element that shows the blur (hazeEffect):
@Composable
fun GlassScreen(content: @Composable () -> Unit, overlay: @Composable BoxScope.() -> Unit) {
val hazeState = rememberHazeState()
Box {
Box(Modifier.hazeSource(hazeState)) { content() } // what's behind the glass
GlassSurfaceAtom(hazeState, Modifier.align(Alignment.BottomCenter), content = overlay)
}
}
@Composable
fun GlassSurfaceAtom(
hazeState: HazeState,
modifier: Modifier = Modifier,
cornerRadius: Dp = LocalRadius.current.lg,
content: @Composable BoxScope.() -> Unit,
) {
val shape = RoundedCornerShape(cornerRadius)
Box(
modifier = modifier
.clip(shape)
.hazeEffect(state = hazeState, style = HazeMaterials.thin()) // the frosted glass
.border(1.dp, Color.White.copy(alpha = 0.35f), shape)
.padding(LocalSpacing.current.lg),
content = content,
)
}
(Haze documentation) – check it for the platform support and API of the version you use. Without Haze, fall back to a translucent fill without blur.
In Einsatzlog, deliberately not. A logbook read at 3 am in a command vehicle needs contrast, not translucency. The message-type colours are the primary scanning aid, and glass would wash them out. Atomic Design makes this a local decision: if we ever want glass, it’s one surface atom and a token, not a rewrite.
8) Testing the levels
Compose Multiplatform has a common UI testing API, runComposeUiTest { … }, that runs in commonTest. Test at the lowest level possible – atoms first – and compose upwards. (JetBrains: Testing Compose Multiplatform UI)
@OptIn(ExperimentalTestApi::class)
@Test
fun primaryButtonRendersTextAndCallsHandler() = runComposeUiTest {
var clicked = false
setContent { AppTheme { PrimaryButtonAtom("Buy", onClick = { clicked = true }) } }
onNodeWithText("Buy").assertIsDisplayed().performClick()
assertTrue(clicked)
}
In Einsatzlog the logic sits below the UI and is tested there (25 unit tests: ViewModels, repository, search normalisation, suggestions, PDF model); the components are covered by previews and by the screenshot generator, which renders every screen in both themes and languages on each run.
9) Documentation in the repo
- A README per level (
atoms/README.md…): purpose, parameters, tokens used, a preview, a usage snippet. - A changelog for tokens and breaking changes.
- A component catalogue – a small sample app or a preview gallery, navigable by atomic level. (Brad Frost: Atomic Design and Storybook)
10) Starter checklist
- Tokens: spacing, radius, elevation, colours, typography via
CompositionLocals - Atoms: inputs, buttons, icons, chips – stateless, slots, semantics built in
- Molecules: search field, labelled field, toolbar action with badge
- Organisms: top app bar, navigation rail, card list
- Templates / pages (or, like Einsatzlog, screens)
- Theming: M3 colour scheme plus your tokens; resources via
Res.* - Testing: atom and molecule tests with the common UI test API
11) Atomic Design vs. Liquid Glass
| Aspect | Atomic Design (method) | Liquid Glass (iOS 26 look) |
|---|---|---|
| What it is | A five-level method to structure components, from atoms to pages | Apple’s visual and interaction language: translucent, glass-edged, dynamic materials |
| Scope | Architecture, naming, responsibilities, reuse | Aesthetics, materials, motion, platform conventions |
| Portability | Technology-agnostic (Compose, SwiftUI, React …) | Apple-platform specific, adopted via Apple’s SDKs |
| In KMP | Implement the levels in common code, powered by tokens and M3 | Emulate the look with a glass surface atom (e.g. Haze) plus depth and motion tokens |
| Together | Defines how the UI is structured | Defines how it should look and feel on Apple platforms – mappable onto your atoms |
12) Adopting glass safely: accessibility and motion
Liquid Glass drew criticism for readability, and Apple adjusted the frosting during the betas. (The Verge) If you adopt it, give people a way out:
@Immutable
data class AccessibilityPrefs(val reduceTransparency: Boolean = false, val reduceMotion: Boolean = false)
val LocalA11yPrefs = staticCompositionLocalOf { AccessibilityPrefs() }
Use these preferences to turn blur and alpha down and to simplify transitions.
13) Putting it together
@Composable
fun HomePageScreen() = AppTheme {
TwoPaneTemplate(
sidebar = { Text("Filters") },
content = {
AppTopBarOrganism(title = "Catalog", actions = { PrimaryButtonAtom("New", onClick = { /* … */ }) })
Spacer(Modifier.height(LocalSpacing.current.md))
// organisms and molecules with real content
},
)
}
TL;DR
- Tokens first (
Spacing,Radius, colours, accessibility preferences), exposed viaCompositionLocal. - Atoms stateless, slot-based, token-driven.
- Molecules from atoms, emitting events, minimal state.
- Organisms for real sections; templates for layout; pages for content – or collapse the last two into screens, as Einsatzlog does.
- One Material 3 theme across platforms, resources via
Res.*. - For an iOS 26 look, a reusable glass surface atom – with switches for reduced transparency and motion.
Further reading
- Atomic Design, chapter 2 – Brad Frost
- Compose Multiplatform and Jetpack Compose and Multiplatform resources – JetBrains
- Locally scoped data with CompositionLocal – Android Developers
- Testing Compose Multiplatform UI – JetBrains
- Apple introduces a new software design – Apple Newsroom; coverage – The Verge
- Haze – multiplatform backdrop blur
- The Einsatzlog UI code: github.com/Einsatzlog-Team/etb (
ui/src/commonMain/.../ui/components)
#BuildInPublic