---
title: "Type Mappings"
description: "How .slint property types map to C++ types, plus the generated classes for structures and enums."
---
import SlintRef from "../../components/SlintRef.astro";

The types used for properties in `.slint` design markup each translate to specific types in C++.
The follow table summarizes the entire mapping. The `.slint` types link to the Slint language reference:

| `.slint` Type | C++ Type | Note |
| --- | --- | --- |
| <SlintRef type="int" /> | `int` | |
| <SlintRef type="float" /> | `float` | |
| <SlintRef type="bool" /> | `bool` | |
| <SlintRef type="string" /> | [`slint::SharedString`](../api/slint/sharedstring/) | A reference-counted string type that uses UTF-8 encoding and can be easily converted to a `std::string_view` or a `const char *`. |
| <SlintRef type="color" /> | [`slint::Color`](../api/slint/color/) | |
| <SlintRef type="brush" /> | [`slint::Brush`](../api/slint/brush/) | |
| <SlintRef type="image" /> | [`slint::Image`](../api/slint/image/) | |
| <SlintRef type="physical-length" /> | `float` | The unit are physical pixels. |
| <SlintRef type="length" /> | `float` | At run-time, logical lengths are automatically translated to physical pixels using the device pixel ratio. |
| <SlintRef type="duration" /> | `std::int64_t` | At run-time, durations are always represented as signed 64-bit integers with millisecond precision. |
| <SlintRef type="angle" /> | `float` | The angle in degrees. |
| <SlintRef type="relative-font-size" /> | `float` | Relative font size factor that is multiplied with the `Window.default-font-size` and can be converted to a `length`. |
| <SlintRef type="struct" label="structure" code={false} /> | A `class` of the same name | The order of the data member are in the same as in the slint declaration. |
| anonymous object | A `std::tuple` | The fields are in alphabetical order. |
| <SlintRef type="enum" code={false} /> | An `enum class` | The values are always converted to CamelCase. The order of the values is the same as in the declaration. |
| <SlintRef type="data-transfer" /> | [`slint::DataTransfer`](../api/slint/datatransfer/) | Data associated with a drag-drop transfer. |
| <SlintRef type="styled-text" /> | [`slint::StyledText`](../api/slint/styledtext/) | Styled text parsed from markdown or plain text. Use `StyledText::from_markdown()` or `StyledText::from_plain_text()` to create. |
| <SlintRef type="Point" /> | [`slint::LogicalPosition`](../api/slint/logicalposition/) | A struct with `x` and `y` fields, representing logical coordinates. |

## Structures

The Slint compiler generates a `class` with all data members in
the same order for any user-defined, exported `struct` in the `.slint`
code.

For example, this `struct` in a `.slint` file

```slint
export struct MyStruct {
    foo: int,
    bar: string,
}
```

will generate the following type in C++:

```cpp
class MyStruct {
public:
    int foo;
    slint::SharedString bar;
};
```

## Enums

The Slint compiler generates an `enum class` with all values in the same order and converted to camel case
for any user-defined, exported `enum` in the `.slint` code.

For example, this `enum` in a `.slint` file

```slint
export enum MyEnum { alpha, beta-gamma, omicron }
```

will generate the following type in C++:

```cpp
enum class MyEnum { Alpha, BetaGamma, Omicron };
```