# 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.

From "Design systems", a free course by Venkat R. Murty: https://designervenkat.online/learn/design-systems/units

## 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.

- **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.

## Worked example: a primary checkout button

Imagine a checkout screen with a Pay now button. It is the primary button, which means it is the main action the user should take on that screen. The team uses a 4px base unit. Here is how the designer sets its size, step by step.

1. **Check the height against the base:** Set the height to 48px. Divide 48 by the 4px base and you get 12, so the height is 12 times the base unit. It sits on the scale.
2. **Record the design value:** In the design file, the button is 48px tall. Write this in the spec with its unit, so nobody has to guess what 48 means.
3. **Set the label to rem:** Set the label text to 1rem. With the usual 16px root size, 1rem is 16px. Write this in the spec too, with the root size stated.
4. **Write the web equivalent:** In web terms, the button becomes 3rem tall, because 48 divided by 16 is 3. The label stays 1rem. Both values follow the root font size.
5. **Test a bigger user setting:** Suppose a user raises their browser default text size so the root becomes 20px. The label is now 1rem times 20, which is 20px. The button height is 3rem times 20, which is 60px. Both grow together, so the label keeps its room inside the button.

Compare this with a button whose height is fixed at 48px and whose label is fixed at 16px. The text would grow to the user's larger size inside a box that did not grow with it, which risks crowding or cutting off the label. Using rem for both values keeps the button and its text in proportion.

> **Tip:** The example assumes the usual 16px root size. If your team sets a different root size, the rem values change. Write the root size at the top of the spec so the numbers can be checked.

## 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?

A. Keep px and set a larger starting value for every text style
B. dp, because it scales the layout to the screen
C. sp, because it follows the user's font size setting
D. A percent of the screen width

**Answer:** C. sp is Android's scalable pixel for text. It grows with the user's font size preference, while px stays fixed. dp is for sizes such as buttons and gaps, not for text.

**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?

A. Keep 30px, because 30 is a multiple of 10
B. Change it to 32px, the nearest multiple of 8
C. Change it to 24px, because it is a lower step
D. Change it to 30rem so it can scale

**Answer:** B. Layout spacing should default to 8 or its multiples. 30 is between 24 and 32, and 32 is the nearest step on the scale. Using rem for padding would not fix the off-scale value.

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)](https://engage.agency/blog/em-vs-rem-vs-px)
- [px vs em vs rem: Which CSS Unit Should You Use? (CSS Toolkit)](https://csstoolkit.net/blog/px-vs-em-vs-rem-guide/)
- [Px vs Rem vs Em: A Complete Guide to CSS Units (DelightfulDev)](https://delightfuldev.com/blog/px-rem-em-css-units-guide/)
- [PX vs REM vs EM in CSS: What's the Difference? (WebEasier)](https://webeasier.com/blog/px-vs-rem-vs-em-css-guide/)
- [REM vs PX: Which CSS Unit to Use (InspoAI)](https://www.inspoai.io/blogs/rem-vs-px)
- [rem vs em vs px: CSS Units Guide (Frontend Hero)](https://frontend-hero.com/rem-vs-em-vs-px)
- [CSS Units Guide: px vs rem vs em vs vh Compared (Frontend Tools)](https://www.frontendtools.tech/blog/css-units-responsive-design-2025)
- [em vs. px in CSS (Educative)](https://educative.io/edpresso/em-vs-px-in-css)
- [Grids and units, Mobile (Android Developers)](https://developer.android.com/design/ui/mobile/guides/layout-and-content/grids-and-units)
- [Support different pixel densities (Android Developers)](https://developer.android.com/training/multiscreen/screendensities)
- [Density Independent Pixels Explained (Design System Problems)](https://designsystemproblems.com/cross-platform-consistency/density-independent-pixels/)
- [Mastering Android UI Units: px, dip, dp, and sp Explained (Lineserve)](https://www.lineserve.net/blog/mastering-android-ui-units-the-complete-guide-to-px-dip-dp-and-sp-explained)
- [Device-independent pixel (Wikipedia)](https://en.wikipedia.org/wiki/Device-independent_pixel)
- [Pixel and Screen Densities in Android and iOS (Design Bootcamp on Medium)](https://medium.com/design-bootcamp/pixel-and-screen-densities-in-android-and-ios-646b5f5ba506)
- [The Basics of 8-Point Grid Systems (This Design Girl)](https://thisdesigngirl.com/ui-design/eight-point-grid/)
- [The 8-Point Grid System: A Guide to Consistent Spacing (Thridy)](https://thridy.com/blog/the-8-point-grid-system-how-spacing-in-eights-makes-ui-feel-consistent)
- [Why Clean Interfaces Often Start With an 8-Point Grid (Hollands Web)](https://hollandsweb.com/8-point-grid-ui-design/)
- [The Verifiable Grid: Why 8-Point Spacing Is the First Design Decision (Design Agent)](https://design-agent.dev/blog/8pt-grid-spacing-agent-perspective/)
- [What Is the 8-Point Grid System in UI Design? (WP Dean)](https://wpdean.com/what-is-the-8-point-grid-system/)
- [Mastering the 8-Point Grid: Building Scalable Spacing Systems (Tim Graf)](https://timgraf.com/ui/mastering-the-8-point-grid-building-scalable-spacing-systems-for-modern-design-systems/)
