Compose’s own Dp , Color and TextUnit are value classes. Here's why.
@JvmInline value class ShipmentId(val raw: String) reads like a free upgrade: a real type in the source, a plain String at runtime. Most of the time that is exactly what you get. Sometimes the compiler quietly allocates a wrapper object anyway, and sometimes the erasure itself causes trouble in Room, Retrofit, Java callers or your logs. This post walks through both halves so you can decide where value classes earn their keep.
Compose layout and drawing code touches sizes and colors constantly, often many times per frame. Wrapping each one in a heap object would add up, so the toolkit wraps primitive-backed values instead and lets the compiler erase the wrapper. Dp wraps a Float and TextUnit wraps a Long . Color wraps a ULong , which is itself a value class that lowers to a plain long on the JVM. You can borrow the same trick in app code.
1.…