KDE Visual Design Group/HIG/Units

Jump to: navigation, search

Purpose

This pages gives an overview about different units used in KDE and Plasma

Pixel

A (physical) pixel or dot is a physical point in a raster image, or the smallest addressable element in an all points addressable display device. Be careful not to confuse it with DPI independent pixels

DPI - pixels per inch

Pixel density is the number of (physical) pixels or dots that fit into an inch. Different screens have different DPI.

screen density = screen width (or height) in pixels / screen width (or height) in inches

Different DPIs on desktop and mobile

DPI is often used interchangeably with PPI, pixel per inch.

PPI / DPI independent pixels

A DPI independet pixel is scaled to look uniform on any screen regardless of the DPI. A lot of platforms, eg iOS, Android, the Web, replaced the old (physical) px with a DPI px. So most the time you read about pixel/px they actually talk about DPI independent pixels. Qt (and QML) support DPI independent pixels in newer versions, but because KDE and Plasma support older versions of Qt too, one can not assume that pixels used in Qt or QML apps are DPI independent.

Different DPIs on desktop and mobile

A rectangle defined with physical pixels and DPI independent pixels.



Except explicilty stated otherwise, all HIG pages, draft, mockups, ... pixels/px are always DPI independent pixels.

DPI independent pixels in KDE

As a developer, if you want to use DPI independent pixels use units.devicePixelRatio as a multiplier on physical pixels. Since units.devicePixelRatio is a float, make sure to round the results. Most of the time you want to flour it.

Fonts

Since KDE allows the user to change the font settings any dimensions defined with px, no matter if they are DPI independent or not, make problems together with text.

Using DPI independet pixel with different font setting

base units in plasma

There are special base units in plasma:

  • units.smallSpacing, for mockup and design = 4px
  • units.largeSpacing, for mockup and design = 16px
  • units.gridUnit, for mockup and design = 16px

These are not only DPI independent but scale according to the font settings too.

Using units.smallSpacing with different font setting

A rectangle defined with units.smallSpacing

From design to code

c recomended spacings

If you design try to use the recomended values for margin and paddings, to ensure a uniform appearance. See Placement and Spacing for more details.

Use of base units
1 Row {
2 	spacing: units.largeSpacing
3 	Rectangle {
4 		...
5 	}
6 	Rectangle {
7 		...
8 	}
9 }
1 Row {
2 	spacing: units.smallSpacing
3 	Rectangle {
4 		...
5 	}
6 	Rectangle {
7 		...
8 	}
9 }

Using arbitrary px values

...


Content is available under Creative Commons License SA 4.0 unless otherwise noted.