May you tell me the css unit use in Expo?

Hello everyone, I not sure the unit use in css (width, height, margin, …).

Thank you !!!

The unit is implied to be pixels (px), and I’m pretty sure it’s just like web CSS pixels, i.e. “density independent pixels”. So 20 is 20 hardware pixels on a “1x” display but 40 hardware pixels on a “2x” display (making it appear to be the same as 20 “1x” hardware pixels).

But the point really is that you shouldn’t need to worry about it. It’ll be what you humanly, logically think it is, and the stack will take care of the translation to actual real hardware screen pixels.

Reference: Height and Width · React Native

Hey @veasnabig! Thanks for using Expo

When I got started with react native I used this cool cheat sheet: https://github.com/vhpoet/react-native-styling-cheat-sheet. If I needed any more depth, I used the reference that @alexrussell pointed out.

Let us know if we can help you out with anything specific! If you want to create an example of a problem you’re having, use https://snack.expo.io :slight_smile:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.