Skip to content

Density

Density sets how tall controls and rows are. Use this page to understand which density a screen gets and when to force one.

  • Desktop density is for a mouse or trackpad. Controls are compact.
  • Touch density is for fingers. Controls and rows are taller, and input text is 16px so phones do not zoom in when a field takes focus.

By default, Republic follows the device. A coarse pointer (a touch screen) gets touch density. Everything else gets desktop density. You rarely need to set anything.

To force a density, set data-density on any element. It applies to everything inside.

<body class="rp-root" data-density="touch">
…
<section data-density="desktop">A dense table on a touch device</section>
</body>

data-density="desktop" wins over a touch screen, so you can keep a dense data table compact on a tablet when that is the better choice.

Only the density tokens change. Spacing, type and radii stay the same.

TokenDesktopTouch
--rp-density-control-height36px44px
--rp-density-input-font-size14px16px
--rp-density-list-row48px56px
Desktop density
  • Department of Records
  • Ministry of Examples
Touch density
  • Department of Records
  • Ministry of Examples