Skip to content
Tauri

dpi

A position represented in logical pixels. For an explanation of what logical pixels are, see description of LogicalSize.

2.0.0

new LogicalPosition(x, y): LogicalPosition
ParameterType
xnumber
ynumber

LogicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L219

new LogicalPosition(object): LogicalPosition
ParameterType
objectobject
object.Logicalobject
object.Logical.xnumber
object.Logical.ynumber

LogicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L220

new LogicalPosition(object): LogicalPosition
ParameterType
objectobject
object.xnumber
object.ynumber

LogicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L221

PropertyModifierTypeDefault valueDefined in
typereadonly"Logical"'Logical'Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L215
xpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L216
ypublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L217

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
xnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L263
ynumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L264

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L261

toJSON(): object

object

NameTypeDefined in
xnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L263
ynumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L264

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L268

toPhysical(scaleFactor): PhysicalPosition

Converts the logical position to a physical one.

ParameterType
scaleFactornumber

PhysicalPosition

import { LogicalPosition } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const position = new LogicalPosition(400, 500);
const physical = position.toPhysical(factor);

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L257


A size represented in logical pixels. Logical pixels are scaled according to the window’s DPI scale. Most browser APIs (i.e. MouseEvent’s clientX) will return logical pixels.

For logical-pixel-based position, see LogicalPosition.

2.0.0

new LogicalSize(width, height): LogicalSize
ParameterType
widthnumber
heightnumber

LogicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L21

new LogicalSize(object): LogicalSize
ParameterType
objectobject
object.Logicalobject
object.Logical.heightnumber
object.Logical.widthnumber

LogicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L22

new LogicalSize(object): LogicalSize
ParameterType
objectobject
object.heightnumber
object.widthnumber

LogicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L23

PropertyModifierTypeDefault valueDefined in
heightpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L19
typereadonly"Logical"'Logical'Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L17
widthpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L18

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
heightnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L66
widthnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L65

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L63

toJSON(): object

object

NameTypeDefined in
heightnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L66
widthnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L65

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L70

toPhysical(scaleFactor): PhysicalSize

Converts the logical size to a physical one.

ParameterType
scaleFactornumber

PhysicalSize

import { LogicalSize } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = new LogicalSize(400, 500);
const physical = size.toPhysical(factor);

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L59


A position represented in physical pixels.

For an explanation of what physical pixels are, see description of PhysicalSize.

2.0.0

new PhysicalPosition(x, y): PhysicalPosition
ParameterType
xnumber
ynumber

PhysicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L286

new PhysicalPosition(object): PhysicalPosition
ParameterType
objectobject
object.Physicalobject
object.Physical.xnumber
object.Physical.ynumber

PhysicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L287

new PhysicalPosition(object): PhysicalPosition
ParameterType
objectobject
object.xnumber
object.ynumber

PhysicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L288

PropertyModifierTypeDefault valueDefined in
typereadonly"Physical"'Physical'Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L282
xpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L283
ypublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L284

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
xnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L330
ynumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L331

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L328

toJSON(): object

object

NameTypeDefined in
xnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L330
ynumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L331

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L335

toLogical(scaleFactor): LogicalPosition

Converts the physical position to a logical one.

ParameterType
scaleFactornumber

LogicalPosition

import { PhysicalPosition } from '@tauri-apps/api/dpi';
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const position = new PhysicalPosition(400, 500);
const physical = position.toLogical(factor);

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L324


A size represented in physical pixels.

Physical pixels represent actual screen pixels, and are DPI-independent. For high-DPI windows, this means that any point in the window on the screen will have a different position in logical pixels (@linkcode LogicalSize).

For physical-pixel-based position, see PhysicalPosition.

2.0.0

new PhysicalSize(width, height): PhysicalSize
ParameterType
widthnumber
heightnumber

PhysicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L92

new PhysicalSize(object): PhysicalSize
ParameterType
objectobject
object.Physicalobject
object.Physical.heightnumber
object.Physical.widthnumber

PhysicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L93

new PhysicalSize(object): PhysicalSize
ParameterType
objectobject
object.heightnumber
object.widthnumber

PhysicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L94

PropertyModifierTypeDefault valueDefined in
heightpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L90
typereadonly"Physical"'Physical'Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L88
widthpublicnumberundefinedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L89

__TAURI_TO_IPC_KEY__(): object

object

NameTypeDefined in
heightnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L133
widthnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L132

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L130

toJSON(): object

object

NameTypeDefined in
heightnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L133
widthnumberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L132

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L137

toLogical(scaleFactor): LogicalSize

Converts the physical size to a logical one.

ParameterType
scaleFactornumber

LogicalSize

import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = await appWindow.innerSize(); // PhysicalSize
const logical = size.toLogical(factor);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L126


A position represented either in physical or in logical pixels.

This type is basically a union type of LogicalSize and PhysicalSize but comes in handy when using tauri::Position in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into tauri::Position

So instead of

import { invoke } from '@tauri-apps/api/core';
import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
const validPosition = position instanceof LogicalPosition
? { Logical: { x: position.x, y: position.y } }
: { Physical: { x: position.x, y: position.y } }
await invoke("do_something_with_position", { position: validPosition });

You can just use Position

import { invoke } from '@tauri-apps/api/core';
import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPosition
const validPosition = new Position(position);
await invoke("do_something_with_position", { position: validPosition });

2.1.0

new Position(position): Position
ParameterType
positionLogicalPosition | PhysicalPosition

Position

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L375

PropertyTypeDefined in
positionLogicalPosition | PhysicalPositionSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L373

__TAURI_TO_IPC_KEY__(): object

object

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L391

toJSON(): object

object

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L400

toLogical(scaleFactor): LogicalPosition
ParameterType
scaleFactornumber

LogicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L379

toPhysical(scaleFactor): PhysicalPosition
ParameterType
scaleFactornumber

PhysicalPosition

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L385


A size represented either in physical or in logical pixels.

This type is basically a union type of LogicalSize and PhysicalSize but comes in handy when using tauri::Size in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into tauri::Size

So instead of

import { invoke } from '@tauri-apps/api/core';
import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
const validSize = size instanceof LogicalSize
? { Logical: { width: size.width, height: size.height } }
: { Physical: { width: size.width, height: size.height } }
await invoke("do_something_with_size", { size: validSize });

You can just use Size

import { invoke } from '@tauri-apps/api/core';
import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
const validSize = new Size(size);
await invoke("do_something_with_size", { size: validSize });

2.1.0

new Size(size): Size
ParameterType
sizeLogicalSize | PhysicalSize

Size

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L177

PropertyTypeDefined in
sizeLogicalSize | PhysicalSizeSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L175

__TAURI_TO_IPC_KEY__(): object

object

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L193

toJSON(): object

object

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L202

toLogical(scaleFactor): LogicalSize
ParameterType
scaleFactornumber

LogicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L181

toPhysical(scaleFactor): PhysicalSize
ParameterType
scaleFactornumber

PhysicalSize

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L187


© 2025 Tauri Contributors. CC-BY / MIT