dp → Size and spacing
Padding, card dimensions, corner radius, icon sizes. Density-independent so the same UI remains visually consistent across resolutions.
A visual guide for product & UI designers
Should you change font sizes for every phone? Usually, no. Understand the difference between density, text scaling, and responsive layouts—then try the live preview.
In Compose Multiplatform, we define spacing and component sizes in dp, and text sizes in sp. The framework handles screen density; sp also follows the user's text-size preference. We adjust layout for width, not every font just because a phone has more pixels.
Padding, card dimensions, corner radius, icon sizes. Density-independent so the same UI remains visually consistent across resolutions.
Like dp, plus accessibility font scaling. Text can grow when the user increases the preferred text size on Android or iOS.
A narrower screen wraps content. A wider layout may show more columns. Font-size changes are optional, intentional design decisions.
Change one variable at a time to see what actually changes.
Resolution and density are not the same thing as screen width.
Each blue bar is exactly 160 dp wide in logical layout. A higher density uses more physical pixels to render that same size.
Simplified scale-factor examples. Actual Android device densities can be fractional, and real devices may apply display scaling.
Two independent rules explain most designer-to-developer handoffs.
Stays at 16 logical layout units, even when you switch from a 1× to a 3× display.
Keeps the same typography token across phones, but system font preferences can enlarge its rendered text.
A larger available window may use different columns, spacings, or an intentional tablet type scale.
For the native apps and shared Compose Multiplatform screens.
At a standard 1× design reference, use logical design values—not screenshots multiplied by device scale.
| Design property | Compose Multiplatform | Native Android | Native iOS |
|---|---|---|---|
| Spacing, icon & component size | dp e.g. 16.dp | dp e.g. 16dp | pt (points) e.g. 16pt |
| Text sizes | sp e.g. 16.sp | sp e.g. 16sp | pt + Dynamic Type Prefer semantic text styles |
| Accessible text scaling | sp supports Android font settings and iOS Dynamic Type | System font settings; Android 14+ may scale nonlinearly | Dynamic Type when implemented with scalable text styles or metrics |
| Responsive decisions | Available window width / size classes | Available window width / size classes | Size classes / available width |
| Figma handoff | Specify logical spacing and reusable type tokens | 1× reference dimensions map to dp values | 1× reference dimensions map to point values |