Units: How Design Systems Measure Size and Space
Learn the measurement units a design system uses, how a base unit such as 8 keeps sizes predictable, and how to pass unit values from design to code.
In short
Units are the measurements a design system uses for size and space, and a base unit such as 8 keeps sizes predictable and easy to pass from design to code.
12 min readFree
What is a unit and why does it matter?
Every button, box, and gap on a screen has a size. A unit is the measuring stick that gives that size a number. A design file might say a button is 48 tall, but a developer still has to decide what that 48 means on a real phone or in a web browser. If the team has not agreed on the unit, two people can build two different buttons from the same design.
A design system is a shared set of parts and rules. Units are one of those rules. They answer three questions. What is the measuring stick? What is the smallest step that sizes are built from? How does a size react when the screen or the user's settings change? This lesson answers all three.
Key words
- Unit
- A named measuring stick, such as a pixel, that gives a size its value.
- Pixel (px)
- A reference unit in CSS, not necessarily one physical screen dot. In design files, px is a common fixed measure.
- Absolute unit
- A unit with a fixed size. It does not change when the user changes a setting.
- Relative unit
- A unit measured from something else, so it can grow or shrink when that other thing changes.
- Root font size
- The base text size for the whole page. Browsers usually start at 16px unless a user or a site changes it.
- Base unit
- The smallest agreed step that other sizes are built from, such as 4 or 8.
- Multiple
- The result of multiplying a number by a whole number. 24 is a multiple of 8 because 8 times 3 is 24.
- Density-independent pixel (dp)
- An Android unit that keeps a size looking about the same on screens with different pixel counts.
- Point (pt)
- The iOS unit that does a similar job to dp.
- Scalable pixel (sp)
- An Android unit for text that also grows with the user's font size setting.
- Handoff
- The step where a designer passes finished values to the people who build the product.
Tip
Write the unit next to every value in your spec. The word 48 alone is unclear. 48dp or 48px tells a developer exactly what you meant.
What are absolute and relative units?
Units fall into two families. Absolute units keep the same size no matter what else changes. Relative units are measured from something else, so they follow that thing. Knowing the family tells you how a size will behave when a user turns up their text size or opens the screen on a different device.
px (pixel): fixed
A pixel is an absolute unit. 16px means 16px everywhere, even when the user changes their browser text size. Pixels suit borders, thin lines, and small fixed details, but they are a poor choice for text.
rem: relative to the page
A rem is measured from the root font size. When the root is the usual 16px, 1rem is 16px. Because rem follows the root, it grows when the user raises their default text size, and the layout grows with it.
em: relative to its own element
An em is measured from the text size of the element it sits in. Padding inside a button can use em so it grows with that button's label. Em values build on each other when elements are nested, so use them with care.
%: a share of the space around it
A percent is a share of the space around the element, such as its parent box. Guides point to percent for containers that should stretch with the space they fill.
vw and vh: tied to the window
vw is a share of the window width and vh is a share of the window height. They are listed with rem, em, and percent as scalable options for layouts that adapt to the screen.
dp and pt: mobile sizes
dp is Android's density-independent pixel. pt is iOS's point. Both keep the physical size of an element roughly steady across screens with different pixel densities, which makes them the normal choice for mobile sizes and spacing.
sp: mobile text
sp is Android's scalable pixel. It works like dp but also follows the user's font size preference, so it is the usual unit for Android text.
The rule of thumb in most guides is simple. Use absolute units for things that should stay exact, and relative units for things that should respond to the user. Real products mix both in the same system.
Tip
Ask one question about each value: should this size change if the user changes their text size? If yes, choose a relative unit or sp or pt. If no, a fixed unit is fine.
How do you choose the right unit?
Once you know the families, choosing a unit for each kind of part becomes a short checklist. The same checklist works for most teams, with the platform names changed for each product.
Text on the web
Use rem for font sizes. Guides agree that px font sizes ignore a user's browser text setting, while rem respects it. This is the main reason to avoid px for body copy and headings.
Text on Android
Use sp. Text in sp grows with the user's font size preference, so the same screen stays readable for people who need larger type.
Borders and hairlines
Use px on the web, for example for a 1px border. A line that is meant to stay thin does not need to grow with the text.
Padding inside a component
Use em when the space should track the component's own text. Button padding is the common example, because a bigger label should get a bigger button.
Sizes and spacing on mobile
Use dp on Android and pt on iOS. These units keep a 48-unit button looking about the same size on screens with different densities.
Tip
Do not use px for font sizes. A user with a larger default text size will not see the change. Use rem on the web and sp on Android.
What are the base unit and the scale?
Choosing units is only half the job. A design system also needs a base unit, the smallest step that everything else is built from. Most teams pick 8. Some pick 4. The 8-point method says that every size, gap, and padding should be a multiple of the base unit. With 8, the scale is 8, 16, 24, 32, 40, 48, and so on.
A base unit keeps sizes predictable. When a designer needs a gap, they pick a value from the scale instead of guessing by eye. Developers see the same values, so the built screen matches the design. Many guides also note that a small set of values works better than an endless choice, because it stops small random differences from piling up.
Some systems use 4 as the base instead, which gives more options for small details.
Real systems show the pattern. These are examples of how the idea is used, not rules you must copy.
- 1
Pick the base
Choose 8 for most product teams. Choose 4 only if your product needs very fine control over small details.
- 2
Write the scale
List the values you will use, for example 4, 8, 16, 24, 32, 48, and 64. Guides suggest starting with a short list and adding values only when the product truly needs them.
- 3
Snap new sizes to the scale
When a new component needs a size, pick the nearest value on the scale instead of inventing a new one.
- 4
Use the half step with care
Use 4 for small details such as icons, text lines, and tight gaps. Keep larger layout spacing on 8 or its multiples.
- 5
Share the list
Put the scale in the design system documentation so every designer and developer uses the same values.
How do you hand units from design to code?
Designers and developers often use different unit names for the same idea. Handoff is the moment the values move from the design file to the product. If the units do not map cleanly, the built screen will not match the design, even when the numbers look right.
Design files (Figma)
A design drawn at 2x needs dividing, so 48px at 2x equals 24dp.
Android
Android uses dp for sizes and sp for text. The number of real pixels grows with density, so the physical size stays about the same.
iOS
iOS uses pt. A point is one pixel on older non-Retina screens, and more pixels on Retina screens. Like dp, it keeps the size steady across devices.
Web
Web documentation often uses px for fixed details and rem or em for relative sizes. Use the same base number as the other platforms, even when the unit names differ.
Some tokens can be stored as plain numbers and turned into the right unit when the product is built. A spacing value of 16 can become 16dp on Android and 16pt on iOS. The number stays the same, and the platform adds its own unit. How tokens are stored and named is covered in a later lesson.
- 1
State the design scale
At the top of the spec, say whether the design file uses a 1x or 2x scale.
- 2
Name the unit for each value
Write 48dp, 48pt, or 3rem, not just 48. Show one unit per platform.
- 3
Write the conversion
For web text, state the root size and the rule, for example rem equals px divided by 16. For Android, state how dp becomes pixels at each density.
- 4
Keep one row per value
Use a small table where each row holds one design value and its Android, iOS, and web equivalent. Developers can then check each part against the same row.
- 5
Test on a real screen
Check the built screen on two densities and with a larger text setting. Fix any part that does not change the way the spec says.
Tip
Keep the same base number on every platform. Even when the unit names differ, a value of 16 on the scale should mean the same spacing on web, Android, and iOS.
Check your understanding
Try these two short scenarios. Each one needs the ideas above to answer it.
Quick check
Your team's phone app sets all of its text in px. A user with low vision raises the phone's default font size, but the app text does not change. Which unit should the text use?
Quick check
A card's padding in the spec is 30px. The team's base unit is 8, and the 4px half step is only for small details. What should the designer do?
In short, a unit is a measuring stick, and a design system uses only a few of them on purpose. Use rem for text on the web, sp for text on Android, px for thin fixed details, and dp or pt for mobile sizes. Build every value from one base unit such as 8, and write the unit beside each number when you hand it off. When you do this, the same design looks right on small screens, large screens, and user settings you may never test yourself.
Sources
- EM vs REM vs PX: When to Use Each CSS Unit (Engage)
- px vs em vs rem: Which CSS Unit Should You Use? (CSS Toolkit)
- Px vs Rem vs Em: A Complete Guide to CSS Units (DelightfulDev)
- PX vs REM vs EM in CSS: What's the Difference? (WebEasier)
- REM vs PX: Which CSS Unit to Use (InspoAI)
- rem vs em vs px: CSS Units Guide (Frontend Hero)
- CSS Units Guide: px vs rem vs em vs vh Compared (Frontend Tools)
- em vs. px in CSS (Educative)
- Grids and units, Mobile (Android Developers)
- Support different pixel densities (Android Developers)
- Density Independent Pixels Explained (Design System Problems)
- Mastering Android UI Units: px, dip, dp, and sp Explained (Lineserve)
- Device-independent pixel (Wikipedia)
- Pixel and Screen Densities in Android and iOS (Design Bootcamp on Medium)
- The Basics of 8-Point Grid Systems (This Design Girl)
- The 8-Point Grid System: A Guide to Consistent Spacing (Thridy)
- Why Clean Interfaces Often Start With an 8-Point Grid (Hollands Web)
- The Verifiable Grid: Why 8-Point Spacing Is the First Design Decision (Design Agent)
- What Is the 8-Point Grid System in UI Design? (WP Dean)
- Mastering the 8-Point Grid: Building Scalable Spacing Systems (Tim Graf)
Last updated on 17 November 2026
Related lessons
- Design systemsUnit Testing: Automated Checks That Prove Each Component Still Works
- Design systemsPerformance: How Design Choices Keep Design System Parts Fast
- Design systemsDesign Editor: Set Up One Shared Design System File Your Team Can Trust
- Design systemsDesign Language: The Look, Feel, and Voice Behind a Design System
Learn with me
Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.